Score:0

Error 502, phpinfo() directing to 7.4 when 8.1 is installed (File not found)

hm flag

I'm setting up a web server. I have a freshly installed Ubuntu 22.04, nginx (welcome page works), and php-fpm which installed php8.1 and php-fpm8.1.

To test PHP, I created a /var/www/<my domain>/info.php which just includes:

<?php
phpinfo(); ?>

Browsing to this page gives Error 502 - Bad Gateway.

Checking /var/log/nginx/error.log shows this:

connect() to unix: /var/run/php/php7.4-fpm.sock failed (2: No such file or directory)

I verified that /var/run/php contains php8.1-fpm.sock but indeed not php7.4-fpm.sock

What is causing the request to look for php7.4? How can I fully configure 8.1 so as not to be reliant on old/multiple versions of php?

Score:0
in flag

You need to configure the path of the fpm php module to use in /etc/nginx/sites-available/default config file:

location ~ \.php$ {
    ...
    # Nginx php-fpm sock config:
    fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    ...
}

So edit "/etc/nginx/sites-available/default" and change from

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

to

fastcgi_pass unix:/run/php/php8.1-fpm.sock;

and restart nginx

Wiley Rush avatar
hm flag
Thank you, this worked! The issue was that I copied a tutorial that used the 7.4 path in the config file.
Jannes Botis avatar
in flag
@WileyRush Please consider marking the answer as accepted if it solved your issue.
Wiley Rush avatar
hm flag
Done! Sorry, didn't realize I had unlocked that ability.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.