-->

Nginx configuration with Magento 1.8

2020-03-25 04:19发布

问题:

anybody knows how to configure server {} in configuration file of nginx server? I have something like this below:

server {
  server_name   local.com;

  root some_path;

  index index.php;

  #location / {
    #try_files $uri $uri/ index.php;
    #proxy_pass  http://127.0.0.1:9000;
  #}

  # set a nice expire for assets
  #location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
  #  expires    max;
  #  add_header Cache-Control public;
  #}

  # the downloader has its own index.php that needs to be used
  #location ~* ^(/downloader|/js|/404|/report)(.*) {
  #  include fastcgi_params;
  #  fastcgi_index index.php;
  #  fastcgi_param  SCRIPT_FILENAME  $document_root$1/index.php$1;
  #  fastcgi_read_timeout 600;
  #  fastcgi_pass  127.0.0.1:9000;
  #}

  location ~* \.php {
    include               fastcgi_params;
    fastcgi_param         SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_read_timeout  18000;
    fastcgi_pass          127.0.0.1:9000;
  }

  #location ~* ^(/index.php)?(.*) {
  #  include               fastcgi_params;
  #  fastcgi_param         SCRIPT_FILENAME  $document_root/index.php$1;
  #  fastcgi_pass          127.0.0.1:9000;
  #  fastcgi_read_timeout  18000;
  #}

}

Browser returns blank page and doesn't exec php...

EDIT:

After spending some time with nginx configuration and php stuff i ended on having site that in some cases load properly and in some not...

Ex: I have two pages that are identical, but for some reason first is loading lie a charm, and second is loading partially...

Sometimes page is loading half way...

Nginx isn't logging anything...

And for some reason when i try to go to backend, nginx loads frontend with backend url :/

Does anybody can provide me with other magento 1.8 configuration ?

回答1:

After the index directive (actually it doesn't matter where, it's just for legibility) add a try_files directive.

try_files $uri $uri/ /index.php;

By chance I wrote a fuller guide on this: Configuring nginx for Magento



回答2:

Ok, it wasn't memory or database issue, it was... IonCube issue... i was debuging core classes and found that script stops on Enteprise Modules and... if You don't have IonCube installed it just simply display blank page.

But, now Magento returns 404: Page not found...

Thx, guys for help and if You have some advice on second issue fell free to post it here :)

After applying little fix:

/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('', 'store'); //<-this
//Mage::run($mageRunCode, $mageRunType);

Front and Back are loading, but there is an problem with controllers... but not for long !

A and if i type in url /admin nginx will return Input file not found, but when i type index.php/admin it load... part. It's and issue with rewrite and server vars.

EDIT:

I won ! iconv wasn't installed... now everything work except rewriting...

SUMMARY: I need to find a way to properly get server var for index.php file and rewrite index.php to /

Thx for help !



回答3:

In answer to the latter questions about MAGE_RUN_CODE you can do it with the nginx map. See: Coeus Blue Blog Post