Hello,
I am struggling to update my PHP version on my DigitalOcean droplet. It is currently on 7.0.33 and I would like to update it to PHP 7.4+. The ondrej php upgrade method does not work for me so I tried using the sergey-dryabzhinsky repo. Upon getting the php to successfully upgrade to 7.4, my website loads only a Apache screen and no longer links to the web page.
How can I upgrade my PHP from 7.0.33 to 7.4+ without affecting the WordPress installation? I know there must be a way to do this without impacting any directories or configs. Please advise.
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!
Heya @28aa9846729a44cf9f819481fa1755,
Can you tell us why using the ondrej:php repo does not work? Here is the usual way to upgrade PHP version with Apache.
Before making any significant changes to your server, it’s essential to back up your data. You can use the snapshot function:
https://docs.digitalocean.com/products/images/snapshots/
It doesn’t matter that you have tried some stuff, just make sure you back up now before you proceeed
Log in to your server via SSH and run the following commands to update your package lists and upgrade existing packages:
sudo apt update
sudo apt upgrade
You need to add a repository that contains PHP 7.4 packages. The Ondřej Surý PPA is widely used for PHP installations on Ubuntu:
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Once the repository is added, you can install PHP 7.4:
sudo apt install php7.4
Install PHP 7.4 modules that you might need. Commonly used modules include:
sudo apt install php7.4-cli php7.4-fpm php7.4-json php7.4-common php7.4-mysql php7.4-zip php7.4-gd php7.4-mbstring php7.4-curl php7.4-xml php7.4-bcmath php7.4-json
Disable the old PHP 7.0 version to avoid conflicts:
sudo a2dismod php7.0
Enable PHP 7.4 to make it the default version:
sudo a2enmod php7.4
sudo systemctl restart apache2
That is it, it’s a straightforward process.
Can you let me know what errors you hit if you follow it?
ondrej:php does not support ubuntu 18.04 now so this method does not work - I am in the same situation. DO support can you provide an update method for php7.4 on unbuntu18.04 wordpress sites?
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.