1. 普通php 项目
location ~ .php$ {root /usr/share/nginx/html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}
2. 使用其他框架(ThinkPHP)
server {listen 80 default_server;listen [::]:80 default_server;server_name _;root /opt/default;include /etc/nginx/default.d/*.conf;location / {index index.html index.php;# try_files $uri @rewrite;#如果文件不存在则尝试TP解析try_files $uri /index.php$uri;}location ~ .+.php($|/) {root /opt/default;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;#设置PATH_INFO,注意fastcgi_split_path_info已经自动改写了fastcgi_script_name变量,#后面不需要再改写SCRIPT_FILENAME,SCRIPT_NAME环境变量,所以必须在加载fastcgi.conf之前设置fastcgi_split_path_info ^(.+.php)(/.*)$;fastcgi_param PATH_INFO $fastcgi_path_info;#加载Nginx默认"服务器环境变量"配置include fastcgi.conf;}error_page 404 /404.html;location = /40x.html {}error_page 500 502 503 504 /50x.html;location = /50x.html {}}