我把我的 magento 商店从服务器“A”这是在 Apache 上服务器“B”运行 NginX。
复制所有文件和文件夹,导出和导入 SQL DB,用新的 DB 详细信息更改 local.xml 文件,然后运行 DB 连接测试脚本,一切顺利。
服务器“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;
}
}
任何线索都将不胜感激...
答案1
这是您的问题:
location @handler { rewrite / /index.php; }
重写之后,你又回到了原来的location /
位置try_files
,然后又回到原来的位置@handler
,你陷入了无限循环。
这看起来完全是多余的;只需将其删除并直接添加到即可try_files
。
try_files $uri $uri/ /index.php;
答案2
这不是 nginx 的问题。
当访问后端的时候,会调用安全的阻止通知。
看看这个班级Mage_Adminhtml_Block_Notification_Security
:
“_canShowNotification”函数调用另一个函数“_isFileAccessible”,该函数执行POST来获取文件“local.xml”。
答案3
发生这种情况的原因是默认的 nginx 配置不支持 Magento 所需的重写。在您的 nginx 配置文件中,请确保在服务器配置下指定了以下内容。
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}