关于在 mac 下 PHP -fpm 无法访问的问题[救救孩子吧]

查看 25|回复 1
作者:fibroblast   
关于在 mac 下 php-fpm 无法访问的问题
php 8.2 brew 本地安装
nginx 是 docker
请排除 nginx 找不到 index.php 文件的问题
因为在 nginx html 目录下有个 demo.html 文件可以正常访问 即 静态资源可以加载
pm-conf
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 20
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 10
request_slowlog_timeout = 30
slowlog = log/php-fpm-slow.log
nginx-conf
server {
    listen       80;        #监听 80 端口
    listen  [::]:80;
    server_name  localhost;                #也可以填写自己注册的域名
    location / {
        root   /usr/share/nginx/html;        #当前配置的页面文件根目录
        index  index.php index.html index.htm;        #添加 index.php 作为默认首页
    }
    #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;
    }
    # 与 php-fpm 通信的关键设置
    location ~ \.php$ {
         root   /usr/share/nginx/html;        #页面文件根目录
         fastcgi_pass   127.0.0.1:9000;        #php-fpm 的通信端口,由于已经将容器 9000 端口映射到了主机的 9000 端口,所以这里填“主机 ip:9000”也是可以的。
         fastcgi_index  index.php;                #默认主页文件设置
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         fastcgi_param  SCRIPT_NAME      $fastcgi_script_name;
         include        fastcgi_params;
    }
}
nginx 报错
2024/05/14 03:46:10 [error] 25#25: *2 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.65.1, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1:8088"
fpm 日志 只有启动
[14-May-2024 12:05:48] NOTICE: Terminating ...
[14-May-2024 12:05:48] NOTICE: exiting, bye-bye!
[14-May-2024 12:05:48] NOTICE: fpm is running, pid 18393
[14-May-2024 12:05:48] NOTICE: ready to handle connections
直接访问 http://127.0.0.1:9000 也不行
日志无东西
cwcc   
docker 的网络问题一般都是映射端口不当造成的。排查下端口映射是否有问题(-p )。
题外话,mac 下搞 php 开发可以用下 Laravel Herd ,一键安装环境。
您需要登录后才可以回帖 登录 | 立即注册

返回顶部