Need help with nginx and upgrading php5.6 to php7.2

August 14, 2018 3.1k views
Nginx PHP WordPress Ubuntu 16.04

I tried upgrading php from 5.6 to 7.2 following the instructions here.

Installation went fine and checking php -v indicated that my php version was now 7.2.

The final step (Updating Nginx Site to Use New Socket Path) calls for editing the php location block in the sites-enabled/default configuration file from:
fastcgi_pass unix:/var/run/php5-fpm.sock;
to
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;.

Every line of my sites-enabled/default configuration file has been commented out since it was created. My main server configuration is located in sites-available and named “mydomain.com” (there is a shortcut to it located in the “sites-enabled” folder). There was no existing reference to the php5.6 location in this file so I’m not sure how it even worked before this. Adding the following code did not appear to do anything as indicated in my Digital Ocean graphs which showed memory use by php5.6:

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

I restarted nginx after each edit/troubleshooting attempt.

I stupidly tried purging php5.6 to remove it and that caused my site to go down (502 Bad Gateway). I attempted to reinstall php5.6 and remove php7.2 but the site is still down and I can’t figure out why. My server configuration file is the same as it was before attempting the php upgrade and php -v indicates the php version is 5.6

I realize I should have taken a snapshot before but I’m an idiot.

Any advice, tips or guidance would be greatly appreciated. I’m desperate to get my site back online.

1 Answer
Have another answer? Share your knowledge.