我的项目的名字叫o2oshop
本项目的配置为
server {
listen 80;
server_name yzd.o2oshop.com.cn;
access_log /data/logs/nginx/yzd.o2oshop.com.cn.access.log main;
error_log /data/logs/nginx/yzd.o2oshop.com.cn.error.log;
root /data/code/yzd.o2oshop;
index index.html index.htm index.php;
#errorpage
include nginx_errorpage.conf;
#favicon
include nginx_favicon.conf;
#thinkphp
include nginx_thinkphp.conf;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
include nginx_php.conf;
}
下面是nginx_php.conf
location ~ \.php/?.*$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#加载Nginx默认"服务器环境变量"配置
include fastcgi.conf;
#设置PATH_INFO并改写SCRIPT_FILENAME,SCRIPT_NAME服务器环境变量
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
}
nginx_thinkphp.conf:
location / {
index index.htm index.html index.php;
# #访问路径的文件不存在则重写URL转交给ThinkPHP处理
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
nginx_favicon.conf:
location ~ ^/favicon\.ico$ {
root /data/code/www.o2oshop.com.cn;
}
nginx_errorpage.conf:
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}