配置 nginx php5-fpm (更改 domain.com)
server {
listen 80 default;
server_name domain.com;
root /var/www/domain.com;
access_log /var/log/nginx/domain.com.access_log;
error_log /var/log/nginx/domain.com.error_log;
index index.php;
try_files $uri @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php/$1;
}
location ~ \.php {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
此代码不适用于根路径...
例子:
domain.com/parse/a/b --> 有效 domain.com/parse --> 有效
domain.com --> 不工作