Hello. I updated my server to PHP7 for use with WordPress. php -v shows it installed correctly, but WP is still complaining it’s on PHP5.9. From my research, this is because it’s not pointing to the correct instance of PHP. I can’t figure out how to adjust this, and I’ve tried following the upgrade guide step by step several times, to no avail. Any help?
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!
When it comes to apache, you need to install libapache2-mod-php7.0 as mod_php is what Apache uses to handle PHP requests.
When you run php -v from the command line (CLI), you’re using the CLI version of PHP, not the same version that Apache is using. Installing the package above should fix the issue, though you need to remove the current package (for PHP 5.x) first.
By running apt-get remove php5 you’re not removing the previous Apache module.
I would simply remove PHP 5 altogether if you don’t need it, which can be done by running:
apt-get -y remove php5*
and to purge the configuration:
apt-get -y purge php5*
Once you’re done there, I would run:
apt-get -y remove libapache2-mod-php5.x
Where the 5.x is the version of PHP 5 that you installed.
Once you’ve removed PHP 5.x, then you can run:
apt-cache search php7.0
… to find any/all packages available for PHP 7.0. You need to install the module as I noted in my previous post, and then any associated packages that you may need.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.