联系柠檬工作室

参考张晏的Nginx 0.7.x + PHP 5.2.8(FastCGI)搭建胜过Apache十倍的Web服务器(第4版)[原创] 配置完服务器之后,安装Magento时老是提示404错误,到网站搜了一下,主要参考拓森网络-run Magento with Nginx,终于成功

现将经验分享如下:

系统环境:CentOS5.2
Nginx版本:0.7.30
Magento版本:1.3.0

1、修改fcgi.conf
vi /usr/local/webserver/nginx/conf/fcgi.conf

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
修改为
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;

2、修改nginx.conf
在虚拟主机设置:server{…}内添加如下内容
# media
location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico)$ {
root /data0/htdocs/www/;
access_log off;
expires 30d;
}
# pass the PHP scripts to FastCGI socket
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /data0/htdocs/www$fastcgi_script_name;
include fcgi.conf;
}
location ^~ /js/proxy.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME /data0/htdocs/www$fastcgi_script_name;
include fcgi.conf;
access_log off;
expires 30d;
}
location / {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param SCRIPT_FILENAME /data0/htdocs/www/index.php;
include fcgi.conf;
}

3、重启Nginx,使配置生效
kill -HUP `cat /usr/local/nginx/nginx.pid`

相关日志

你可以发表评论引用到你的网站或博客,或通过RSS 2.0订阅这个日志的所有评论。
上一篇:
下一篇:
已有1条评论
test
11/07/2009

参考这篇文章配置Nginx下的Magento http://www.tomssoft.com/node/5

我来说两句

  Ctrl+Enter