My issue:
Loading a PHP file gives 502 Bad Gateway
How I encountered the problem:
I’m attempting to install PHP with NGINX. I’ve install PHP 8.1 and done what I think is the correct config, but i can’t reach index.php on the server. It gives a 502. If I hit index.html all is well.
Solutions I’ve tried:
apt install php-fpm php-mysql
I edited my .conf file.
completed a nginx -t which had no issues
restarted nginx
My config:
nginx 1.26.3
Ubuntu 22.04.5 LTS
my .conf for the domain:
server {
location / {
root /var/www/html/<my folder>
try_files $uri $uri/ /index.php$is_args$args;
}
server_name <domain name>;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php8.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
(other stuff for port 443 ssl )
From experience, it seems the in most recent versions of NGINX, PHP is broken. It works fine in 1.22.1 which is the newest version currently in the Debian repos.
I’ve tried absolutely everything and checked all the troubleshooting guides I can find. I’ve spent way to much time reading and troubleshooting. I’m going to switch to apache over the weekend. I think I can get that working with my current nginx config.