lnmp1.0支持pathinfo模式

首先,在ssh中执行


touch /usr/local/nginx/conf/pathinfo.conf 创建pahtinfo.conf文件

然后在这个文件中添加以下内容


set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info; 再将虚拟主机配置文件里的location ~ .*\.(php|php5)?$ 替换为:location ~ .*\.php

再在include fcgi.conf; 下面添加一行include pathinfo.conf;

重启nginx
完整的虚拟主机配置文件如下:

server
{
listen 80;
server_name iw3c.com;
index index.html index.htm index.php;
root /home/wwwroot/iw3c;

location ~ .*\.php
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
include pathinfo.conf;
}

location /status {
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

}

posted @ 2014-08-23 11:10  不再犹豫、  阅读(201)  评论(0编辑  收藏  举报