win10下安装wsl子系统,并成功搭建lnmp环境后,ngixn请求出现502错误。查看nginx日志(/var/log/nginx/error.log)报错以下。php
2020/06/16 11:09:50 [error] 2293#2293: *1 upstream timed out (110: Connection timed out) while reading upstream, client: 192.168.58.102, server: 192.168.xx.xx, request: "POST 你的请求地址 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "192.168.xx.xx", referrer: "你的请求地址"
执行命令查看php-fpm的启动状态,若是没有启动则启动php-fpm便可nginx
/etc/init.d/php7.2-fpm status
或php7
ps -ef|grep php
1.在nginx配置中加一个location,设置以下php-fpm
location ~ ^/status$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; }
2.在php-fpm.conf中打开选项spa
pm.status_path = /status
3.设置完成后便可经过 http://域名/status 看到当前的php状况。示例以下。unix
由于nginx和php有两种链接方法。
链接方式一:日志
fastcgi_pass 127.0.0.1:9000;
链接方式二:code
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
这个具体怎么用要去php-fpm里面去看他的配置文件
/etc/php/7.2/fpm/pool.d/www.conf里面的Listen配置。server
若是Listen是端口就写127.0.0.1:9000;
若是是路径,nginx的配置文件也要是路径,unix:/run/php/php7.0-fpm.sock;blog
确认两个地址配置一直后,重启一下nginx就能够访问了。