'nginx err_connection_refused, can anyone help me?
got installed my old site with php, mysql and so on, an everything work fine but my site is not reachable from the outside of my LAN. Did a ton of changes and tried at least 100 config for my nginx sites-enabled and php7.4 but nothing helped me out :/. Either i get a 502 or connection refused error. Runing on ubuntu 20.04
check this default container:
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;
}
}
and the php www.conf (tested both):
...
;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
do you guys havy any hints, something that i could missed it?
best regards and sorry for my bad english
Solution 1:[1]
Configure a file with error log, like:
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...
Then, restart nginx and check the server.error.log file. With these changes, you can give an idea of what is happening,
Solution 2:[2]
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/ ocation / { ...
location ~ [^/]\.php(/|$) {
...
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
} BUT
netstat -tulpn | grep 9000
... /etc/php/7.3/fpm/pool.d/www.conf => listen = 127.0.0.1:9000
/etc/php/7.3/fpm/pool.d/www.conf => listen = /var/run/fastcgi.sock
listen.allowed_clients = 127.0.0.1 => uncoment
and in nginx.conf location / { ...
location ~ [^/]\.php(/|$) {
....
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
} take a look at "fastcgi_pass" nginx.conf location / { fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; //127.0 replace with php7.*-fpm.sock ! looks like nginx don`t see yuor php-fpm
Solution 3:[3]
it looks like nginx don't see yuor php-fpm so, FIND php-fpm on harddisk and try put the pass into nginx.conf as fastcgi_pass to make it looks like:
fastcgi_pass unix:/var/run/php/php7.*-fpm.sock;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ziscko |
Solution 2 | |
Solution 3 | Code-Apprentice |