首页 > 解决方案 > nginx err_connection_refused,任何人都可以帮助我吗?

问题描述

用 php、mysql 等安装了我的旧站点,一切正常,但我的站点无法从我的局域网外部访问。进行了大量更改并为我的 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
...

网络统计-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    

你们有任何提示,我可能会错过吗?

最好的问候和抱歉我的英语不好

标签: phpnginxwebserver

解决方案


配置带有错误日志的文件,例如:

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 文件。通过这些更改,您可以了解正在发生的事情,


推荐阅读