Skip to content

php+nginx调试记录

约 235 字小于 1 分钟

2023-07-07

启动 php - /usr/bin/php-fpm

  1. 首先 502 Bad Gateway 问题: [crit] 12981#0: *2 connect() to unix:/var/run/php8-fpm.sock failed (13: Permission denied) while connecting to upstream 解决:一般是由于 php8-fpm.sock 没有权限 执行一下 chmod 777 php8-fpm.sock 或者是用户的问题 查看 php 配置文件[www.conf]与 nginx 第一行的用户是否一样 如果 nobody 就不管 重启 sock 还得再开一次权限

问题: [error] 15704#0: *2 FastCGI sent in stderr: "Unable to open primary script: /www/myphp/index.php (No such file or directory)" 解决: 一般是路径问题,找不到脚本,但是好像可以解析图片?? 那应该还是 nginx 解析出来的图片,php 走的 fpm 所有有问题. 办法:配置如下

 	server {
        listen      8008;
        server_name localhost;
        root        /www/;

        location / {
            index   index.php;
        }

        #当请求网站下php文件的时候,反向代理到php-fpm
        location ~ \.php$ {
            fastcgi_pass                unix:/var/run/php8-fpm.sock;
            fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include                     fastcgi_params;
        }
    }