Report this

What is the reason for this report?

How do I update PHP on centos droplet

Posted on November 4, 2025

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!

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.

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:

  1. Check your current PHP version**
php -v
  1. Enable the Remi repository (it provides newer PHP versions)
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.)

  1. See available PHP versions**
sudo yum module list php
  1. Enable the desired version

For example, to switch to PHP 8.2:

sudo yum module reset php -y
sudo yum module enable php:remi-8.2 -y
  1. Update PHP and common extensions
sudo yum update -y
sudo yum install -y php php-cli php-fpm php-mysqlnd php-xml php-json php-opcache
  1. Restart web server

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!

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.