How do I update PHP on centos droplet
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, @kenloomis
You should always back up your site and config files before upgrading PHP, some older CMS or frameworks may need updates to stay compatible.
Here’s the cleanest way to update PHP on a CentOS Droplet:
php -v
sudo yum install -y epel-release
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
(Replace 7 with 8 or 9 depending on your CentOS version.)
sudo yum module list php
For example, to switch to PHP 8.2:
sudo yum module reset php -y
sudo yum module enable php:remi-8.2 -y
sudo yum update -y
sudo yum install -y php php-cli php-fpm php-mysqlnd php-xml php-json php-opcache
If you’re using Apache:
sudo systemctl restart httpd
If you’re using Nginx with PHP-FPM:
sudo systemctl restart php-fpm
sudo systemctl restart nginx
You should now see the new version.
php -v
Hope that this helps!
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.