gpt4 book ai didi

nginx - 索引和根页面不工作,502 Bad Gateway

转载 作者:行者123 更新时间:2023-12-03 23:06:28 25 4
gpt4 key购买 nike

网址 example.org/index.php (和任何 example.org/etc.php)失败 ,但是 example.org/foo工作正常,适用于任何 foo文件夹。

server {
server_name example.org example.com;
access_log /var/log/nginx/example.org.access_log;
root /var/www/example.org/;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =403;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}

  • nginx 版本:1.17.10 (Ubuntu)
  • ? /var/log/nginx/error.log (没有具体针对服务器?)

  • sudo tail /var/log/nginx/error.log什么都不显示,只显示其他站点的错误,
    ...
    2020/06/19 12:58:02 [error] 871296#871296: *23 "/var/www/example2.org/index2.php" is not found (2: No such file or directory), client: 181.177.112.xx, server: example2.org, request: "GET / HTTP/1.0", host: "example2.org"

    解决方案的主要线索(见我的回答)

    文件 /run/php/php7.0-fpm.sock不存在,所以失败在 fastcgi_pass unix:/run/php/php7.0-fpm.sock; .
    ls -l /run/php/*.sock显示
    lrwxrwxrwx 1 root     root     30 May 17 05:18 /run/php/php-fpm.sock -> /etc/alternatives/php-fpm.sock
    srw-rw---- 1 www-data www-data 0 May 29 06:40 /run/php/php7.4-fpm.sock

    理想的是通用套接字,即 php-fpm.sock ,但似乎不一样(不是重定向到 php7.4-fpm.sock ?)。

    最佳答案

    Ideal 是一个通用套接字,但现在使用的是 php7.4-fpm.sock :

    server {
    server_name example.org example.com;
    ...
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
    }

    这个解决方案并不完美(PHP 更改版本时的大问题)但工作正常。

    关于nginx - 索引和根页面不工作,502 Bad Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62407367/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com