Question

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

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.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.