nginx err_connection_refused,有人可以帮助我吗?

问题描述 投票:0回答:3

用 php、mysql 等安装了我的旧网站,一切正常,但无法从 LAN 外部访问我的网站。做了很多改变,并为我的 nginx 站点启用和 php7.4 尝试了至少 100 个配置,但没有任何帮助我:/。我收到 502 或连接拒绝错误。在 ubuntu 20.04 上运行

检查这个默认容器:

    server {
    listen 80; 
    root /var/www; 
    index index.html index.php index.htm index.nginx-debian.html;
    server_name localhost;
    location / {
        try_files $uri $uri/ =404;
    }
    
location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    #fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    fastcgi_pass 127.0.0.1:9000;
    include snippets/fastcgi-php.conf;  
        #fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}
}

和 php www.conf(都测试过):

...
;listen = /var/run/php/php7.4-fpm.sock
listen = 0.0.0.0:9000
...

netstat -lntp:

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      9194/php-fpm: maste 
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1086/mysqld         
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9151/nginx: master  
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      795/systemd-resolve 
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      900/cupsd           
tcp        0      0 127.0.0.1:9050          0.0.0.0:*               LISTEN      1038/tor            
tcp6       0      0 :::33060                :::*                    LISTEN      1086/mysqld         
tcp6       0      0 ::1:631                 :::*                    LISTEN      900/cupsd    

你们有什么提示吗?一些我可能会错过的东西?

致以最诚挚的问候,并为我糟糕的英语感到抱歉

php nginx webserver
3个回答
0
投票

配置一个包含错误日志的文件,例如:

server {
error_log /path/server.error.log;

listen 80; 
root /var/www; 
index index.html index.php index.htm index.nginx-debian.html;
server_name local...

然后,重新启动nginx并检查server.error.log文件。 通过这些更改,您可以了解正在发生的事情,


0
投票
sudo tail -f /var/log/php7.*-fpm.log
ngnix.conf => php-fpm socet?
location ~ \.php$ {
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
include fastcgi_params;
} 

https://saribzhanov.ru/tehno/nastraivaem-rabotu-php-fpm-na-port-ili-na-soket/ 地点/{ ...

location ~ [^/]\.php(/|$) {
    ...

    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    include         /etc/nginx/fastcgi_params;
}

} 但是

netstat -tulpn | grep 9000

... /etc/php/7.3/fpm/pool.d/www.conf => 监听 = 127.0.0.1:9000

/etc/php/7.3/fpm/pool.d/www.conf => 监听 = /var/run/fastcgi.sock

listen.allowed_clients = 127.0.0.1 => 取消注释

以及 nginx.conf 中 地点 / { ...

location ~ [^/]\.php(/|$) {
    ....

    fastcgi_pass    unix:/var/run/php/php7.3-fpm.sock;
    fastcgi_index   index.php;
    include         /etc/nginx/fastcgi_params;
}

} 看看“fastcgi_pass” nginx.conf 地点 / { fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; //127.0 替换为 php7.*-fpm.sock !看起来 nginx 没有看到你的 php-fpm


0
投票

看起来 nginx 没有看到你的 php-fpm,所以,在硬盘上查找 php-fpm 并尝试将 pass 作为 fastcgi_pass 放入 nginx.conf 中,使其看起来像:

fastcgi_pass    unix:/var/run/php/php7.*-fpm.sock;

© www.soinside.com 2019 - 2024. All rights reserved.