600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 无法正常访问nginx服务器的html目录下的php文件

无法正常访问nginx服务器的html目录下的php文件

时间:2021-10-02 20:26:36

相关推荐

无法正常访问nginx服务器的html目录下的php文件

一、nginx.conf文件中fastcgi_param没有修改好根目录的路径

问题描述:访问html目录下的php文件会自动出现另存为对话框

解决方法:修改nginx.conf文件中的fastcgi_param参数

vi /usr/local/nginx/conf/nginx.conf

保存配置并重启服务器:

/usr/local/nginx/sbin/nginx -s stop/usr/local/nginx/sbin/nginx

访问php文件:

二、php-fpm没有开启

访问html文件正常:

访问php文件返回错误:

查看错误日志信息:

tail -1 /usr/local/nginx/logs/error.log/03/18 15:02:28 [error] 2945#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.72.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.72.129"

错误里面有:upstream: "fastcgi://127.0.0.1:9000"

有可能php-fpm没有开启,查看是否开启9000端口:

netstat -antActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 00 0.0.0.0:111 0.0.0.0:*LISTENtcp 00 0.0.0.0:80 0.0.0.0:*LISTENtcp 00 192.168.122.1:53 0.0.0.0:*LISTENtcp 00 0.0.0.0:22 0.0.0.0:*LISTENtcp 00 127.0.0.1:631 0.0.0.0:*LISTENtcp 00 127.0.0.1:25 0.0.0.0:*LISTENtcp 052 192.168.72.129:22 192.168.72.1:62578ESTABLISHEDtcp6 00 :::111 :::*LISTENtcp6 00 :::22 :::*LISTENtcp6 00 ::1:631 :::*LISTENtcp6 00 ::1:25 :::*LISTENtcp6 00 :::3306 :::*LISTEN

没有开启9000端口,执行命令:

php-fpm

/usr/local/src/php-7.2.3/sapi/fpm/php-fpm

访问php页面:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。