Nginx无法解析php页面,status为200,错误日志也什么都没有,
但html页面能够顺利解析。
cenos7系统版本,Nginx版本为1.14,网上的方法基本都尝试过了,在nginx.conf加fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name 没用。
我的nginx.conf内容:
user root;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
server {
listen 8080;
server_name 127.0.0.1;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
root /mnt/hgfs/WWW/ParallelForPhp_new/public;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 last;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
location ~ .php$ {
}
这是我的配置
然后你要看看你有没有启动php-fpm
还有注意你php-fpm.conf文件里面是怎么监听的
如果是:listen = 127.0.0.1:9000就没有问题
如果是:listen = /usr/local/var/php-fpm.sock
你就需要把fastcgi_pass 127.0.0.1:9000;改成fastcgi_pass listen = /usr/local/var/php-fpm.sock