I just upgraded my ubunut server on AWS to Ubuntu 20.04.1 LT from Ubuntu 16.x

I had some issues upgrading at first, but I was able to move past those. Once I upgraded though I could not get nginx to run and actually use my website again.

After looking at my nginx.conf and errors this line was causing an error:

nclude /etc/nginx/sites-enabled/*;

There was the example file in the sites-enabled along with my actual websites file so I changed it to:

include /etc/nginx/sites-enabled/mywebsite.net;

Once I made that issue, I was able to get nginx to start and run but when I tried to view my website I got a 502 error.

While looking at the logs I was able to pull this line:

2020/11/25 15:27:02 [crit] 12327#12327: *1 connect() to unix:/var/run/php/php7.2-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xx.xx.xx, server: www.mywebsite.net, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "www.mywebsite.net"

So I went back into my /sites-enabled/mywebsite.net file and I believe this is what the issue is, for not pointing to the right place for php:

location ~ .php$ {
      fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

But I am not sure what to do for next step to get it pointing to the right location for php?

  • not sure what you mean to change my .sock to match. Here is what ls /var/run/php gives me: php7.0-fpm.pid php7.0-fpm.sock php7.1-fpm.pid php7.1-fpm.sock php-fpm.sock – Mike Jones Nov 25 '20 at 18:58

Assuming you have php-fpm installed, it is started/enabled with systemctl, and it is running properly/configured to use a socket, you should find a .sock file in /var/run/php/ .

ls -lsha /var/run/php

NGINX connects to PHP, according to your configuration, via /var/run/php/php7.2-fpm.sock .

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

I am assuming that during your upgrade, you may have moved off of php7.2-fpm. You will have to determine which version of php-fpm is available on the system, ensure it is running, determine where that socket is, and give that correct socket to the NGINX configuration.

If you've configured your system for 7.2, it doesn't make sense to me that you'd regress to 7.1 in an update. It seems those files are just lying around, but you can tell better by looking at their creation times. Maybe php7.2-fpm is still installed, but not actually running/enabled.

systemctl status php-fpm
  • I tried that last command to see the staus but I got this: Unit php-fpm.service could not be found. I also ran a php - v to check my version and got this: pastebin.com/LWHVr9SW – Mike Jones Nov 25 '20 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.