Disclaimer: this is only a note for myself so I don't have to look for the answer anywhere else.
Once again I find myself configuring nginx to serve a small php app in an ubuntu instance. Following one of the thousands of articles about that I uses this pice of configuration:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
and this line in particular fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
is responsible for generating this connect() to unix:/var/run/php/php7.4-fpm.sock failed
error. I have dealt with this before and I kind of remember the solution I use in the past and it has to do with the port php-fpm is listening to. So I went online look for that and indeed the solution is as follows:
- Edit your
/etc/php/X.X/fpm/pool.d/www.conf
file (replaceX.X
with the version of php you are using) and find the following line:
listen = /var/run/phpX.X-fpm.sock # (replace `X.X` with the version of php you are using)
change it to be:
listen = 127.0.0.1:9000
then go to your nginx config file and update it accordingly fastcgi_pass 127.0.0.1:9000
.