我尝试使用nginx设置我的mangeto网站,但我没有成功。我遵循了本教程:http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento
这是我的配置:
server {
listen 80;
server_name www.mydomainname.com *.mydomainname.com;
root /var/www/mydomainname/web;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
default_type application/octet-stream;
location / {
try_files $uri $uri/ /app.php?$query_string /index.php?$query_string;
}
location /dev {
auth_basic "Restricted Area";
auth_basic_user_file conf/htpasswd;
try_files $uri $uri/ /dev/index.php;
}
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; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
我可以访问mydomainname.com,但当我尝试在子文件夹mydomainname.com/dev/中启动magento安装时,它无法正常工作。我的webbrowser下载php文件而不是执行它。当我用/ var / www / mydomainname / web / dev / it工作改变root时。 你知道为什么吗?
答案 0 :(得分:0)
我的第一个问题是错误502,经过一些测试我将问题暴露在上面。当我重新启动浏览器时没关系,我成功纠正错误502,配置文件为php-fpm!这里有一个教程:http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm!
答案 1 :(得分:0)
原因是PHP根本没有传递给PHP-FPM。请注意,NGINX本身并不会说PHP,它需要一些后端服务器来处理PHP请求。
我怀疑它没有进入位置〜.php $ ...