How do I upgrade my PHP version?
I cannot find anywhere how to do this. Wordpress is telling me an upgrade is required but they tell me to go my hosting company to upgrade PHP. Linode tells me PHP is not part of the services they provide. Any help is much appreciated.
I think I located your account and I took note of your distribution version, so I’ll form my advice around this information. I’m not sure which version of PHP you’re currently running, but the below instructions detail how to upgrade to PHP 7.4 or 8.0.
Before getting started, there’s some risk to consider when upgrading to a PHP version that isn’t native to your distribution version - you can read more details surrounding this in this Community post.
Retrofitting this newer version with your distribution requires you to download a PHP repository, which is covered in these steps.
1) Update server:
sudo apt-get update && apt-get upgrade
sudo apt -y install software-properties-common
3) Add PHP repository
sudo add-apt-repository ppa:ondrej/php
4) Update repository index
sudo apt-get update
5) Install php7.4
sudo apt-get install php7.4
6) Install php extensions (run
dpkg -l php7.4* for list) - these are some common ones:
sudo apt install php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y
Since you’ll now have multiple PHP versions on your server, you’ll want to set this as the default:
update-alternatives --set php /usr/bin/php7.4
If you wanted to install PHP 8.0 instead of 7.4, you could do the following:
sudo apt-get update && apt-get upgrade sudo apt -y install software-properties-common sudo add-apt-repository ppa:ondrej/php apt-get install php7.4 apt-get install libapache2-mod-php7.4 php7.4-fpm libapache2-mod-fcgid php7.4-curl php7.4-dev php7.4-gd php7.4-mbstring php7.4-zip php7.4-mysql php7.4-xml update-alternatives --set php /usr/bin/php8.0
Thank you so much for the help here. If I add on the C-panel will upgrading my PHP be easier through a dashboard of sorts? Or would I still need to run code manually?
@foxkeeper Since it sounds like you already have an existing server, it is mostly easier to follow the instructions @jtoscani laid out. This is because installing cPanel on an existing server will erase the current contents. It is possible to deploy a new server using our cPanel Marketplace App. Then you'd need to transfer your website files over to it. You may find the below links helpful with migrating your data to a new server.
Hi, I have the same issue. The instructions worked great. Thanks. However, my Wordpress site is still giving me a hard time:
PHP is the programming language used to build and maintain WordPress. Newer versions of PHP are created with increased performance in mind, so you may see a positive effect on your site’s performance. The minimum recommended version of PHP is 7.4.
Any idea what the problem might be?
Should have checked …
I just wanted to add a quick note to this. If you are going to be updating PHP in a Debian system, all the instructions above will work except for the command for adding the PHP repo (which is intended for Ubuntu). As per the repo instructions, the commands you want to use for Debian are:
curl -sSL https://packages.sury.org/php/README.txt | sudo bash -x sudo apt update
Hi, everyone! I followed your instructions and in my terminal everything seems to work just fine, when I check the php version is indeed 7.4. However, when I check my Wordpress it says that I have the old version. Does anyone has any idea why is that? Thanks a lot!
Solved: I followed this answer: https://www.linode.com/community/questions/18801/my-website-says-i-need-to-upgrade-php-but-php-v-shows-the-current-version-why