从Apache移动到nginX后的Magento错误404

我将我的magento商店从运行在Apache上的服务器“A”移动到运行NginX的服务器“B”

复制所有文件和文件夹,导出和导入SQL DB,使用新的数据库详细信息更改local.xml文件,然后运行一个数据库连接testing脚本,一切正常。

服务器“A”是http://hns.lwea.co.uk/服务器“B”是http://hotnstylish.co.uk/

当我导航到hotnstylish.co.uk地址我得到一个“默认Magento主题”404错误:页面找不到。

注意: 我以前的这个nginx实例上有另一个magento安装工作正常:(

NginX生成以下错误日志:

2013/12/01 17:43:43 [error] 5520#0: *105 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 17:50:38 [error] 5520#0: *108 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 17:50:40 [error] 5520#0: *111 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 17:50:43 [error] 5520#0: *113 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 17:50:45 [error] 5520#0: *115 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 17:50:48 [error] 5520#0: *117 access forbidden by rule, client: 127.0.0.1, server: 836237.vps-10.com, request: "POST /app/etc/local.xml HTTP/1.1", host: "836237.vps-10.com" 2013/12/01 22:50:22 [error] 5520#0: *143 rewrite or internal redirection cycle while processing "/index.php", client: 92.28.188.240, server: 836237.vps-10.com, request: "GET /index.php/admin/cms_page/index/key/a962fe17df7bb966ff6202585abe3f2f/ HTTP/1.1", host: "836237.vps-10.com", referrer: "http://836237.vps-10.com/index.php/admin/mobile/history/key/1e11fb471a8ce41d1f6c6f54368469ba/" 2013/12/01 22:50:51 [error] 5520#0: *145 rewrite or internal redirection cycle while processing "/index.php", client: 95.211.223.32, server: 836237.vps-10.com, request: "POST /cgi-bin/php/%63%67%69%6E/%70%68%70?%2D%64+%61%6C%75%6F%6E+%2D%64+%6D%6F%64+%2D%64+%73%75%68%6F%6E%3D%6F%6E+%2D%64+%75%6E%63%74%73%3D%22%22+%2D%64+%64%6E%65+%2D%64+%61%75%74%6F%5F%70%72%%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%74%5F%3D%30+%2D%64+%75%74+%2D%6E HTTP/1.1", host: "localhost" 2013/12/01 22:54:02 [error] 5520#0: *146 rewrite or internal redirection cycle while processing "/index.php", client: 23.22.240.96, server: 836237.vps-10.com, request: "HEAD / HTTP/1.1", host: "109.104.94.194" 

和以下访问日志:

 92.28.188.240 - - [03/Dec/2013:15:33:35 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:38:47 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:38:50 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:39:58 +0000] "GET /admin HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:40:02 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 54.194.106.16 - - [03/Dec/2013:15:43:55 +0000] "GET / HTTP/1.1" 404 1627 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)" 92.28.188.240 - - [03/Dec/2013:15:48:06 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:54:30 +0000] "GET / HTTP/1.1" 404 684 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 92.28.188.240 - - [03/Dec/2013:15:54:36 +0000] "GET / HTTP/1.1" 404 683 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 

我的vHost文件如下:

 server { listen 80 default_server; server_name www.hotnstylish.co.uk *.hotnstylish.co.uk; ## Domain is here twice so server_name_in_redirect will favour the www rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www access_log /data/www/public_html/hotnstylish/log/access.log; error_log /data/www/public_html/hotnstylish/log/error.log; root /data/www/public_html/hotnstylish/public/; location / { include /etc/nginx/mime.types; root /data/www/public_html/hotnstylish/public/; index index.html index.htm index.php; ## Allow a static html file to be shown first try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler expires 30d; ## Assume all files are cachable } ## These locations would be hidden by .htaccess normally location ^~ /app/ { deny all; } location ^~ /includes/ { deny all; } location ^~ /lib/ { deny all; } location ^~ /media/downloadable/ { deny all; } location ^~ /pkginfo/ { deny all; } location ^~ /report/config.xml { deny all; } location ^~ /var/ { deny all; } # media location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico)$ { root /data/www/public_html/hotnstylish/public/; access_log off; expires 30d; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; } location /var/export/ { internal; } location /. { return 404; } location @handler { rewrite / /index.php; } location ~* .php/ { rewrite ^(.*.php)/ $1 last; } #location ~* .php$ { #if (!-e $request_filename) { rewrite / /index.php last; } #expires off; location ~ ^(.+\.php)(.*)$ { root /data/www/public_html/hotnstylish/public/; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param MAGE_RUN_CODE default; fastcgi_param MAGE_RUN_TYPE store; include fastcgi_params; } } 

任何线索将不胜感激…

这是你的问题:

  location @handler { rewrite / /index.php; } 

重写后,您将返回到location /并再次通过try_files返回。 然后它返回到@handler ,你在无尽的循环。

这似乎是完全多余的; 只是摆脱它,并直接添加到try_files

  try_files $uri $uri/ /index.php; 

这不是一个nginx问题。

访问后端时,会调用安全通知。

看一下Mage_Adminhtml_Block_Notification_Security类:

“_canShowNotification”函数调用另一个函数“_isFileAccessible”,它执行POST来获取文件“local.xml”。

它发生的原因是因为默认的nginxconfiguration不支持Magento所需的重写。 在你的nginxconfiguration文件中,确保在你的服务器configuration文件中指定了以下内容。

 location / { try_files $uri $uri/ /index.php?q=$uri&$args; }