server {
listen 8008;
root /root/php-test;
index index.php index.html index.htm;
location ~ .php {
#fastcgi_pass unix:/tmp/php/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
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;
include /usr/local/openresty/nginx/conf/fastcgi.conf;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
fastcgi_intercept_errors on;
error_page 500 502 503 504 =200 /50x.php;
location = /50x.html {
root /root/php-test;
}
location ~ /.ht {
deny all;
}
}
重点:
fastcgi_intercept_errors on;
error_page 500 502 503 504 =200 /50x.php;
location = /50x.html {
root /root/php-test;
}
将 /root/php-test/50x.php 返回想要的结果。