I still have a CentOS 7 server running in production. It’s not ideal, but it works. When PHP needed upgrading to 8, I didn’t want a five-hour battle. I wanted the commands that just work.
Here is how you do it on CentOS 7 using the Remi repository.
First, install EPEL if you haven’t already:
sudo yum install epel-release
Then, add the Remi repository and install the necessary tools to manage it. Note that yum-config-manager lives in the yum-utils package, so you need that first.
sudo yum install yum-utils
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
Enable the PHP 8.0 repository. If you want a newer version, swap remi-php80 for remi-php81, remi-php82, or remi-php83. I’d pick 8.3 if your code supports it.
sudo yum-config-manager --enable remi-php80
Update your package list and install PHP:
sudo yum update
sudo yum install php
Verify the installation:
php -v
You should see output like this:
PHP 8.0.30 (cli) (built: ...) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
Why you’re still on CentOS 7
Let’s be honest. CentOS 7 reached end of life on June 30, 2024. Technically, it’s dead. But we all know the reality: legacy systems don’t die when the calendar says they should. They die when you have time to migrate them.
If you are reading this, you probably have a server that can’t be moved yet. Maybe it’s a critical internal tool. Maybe it’s a cheap VPS that runs perfectly fine and you’re scared to touch it. That’s valid.
The “real fix” is migrating to AlmaLinux or Rocky Linux. They are rebuilds of RHEL 8 and 9, so moving from CentOS 7 is a major version upgrade, usually a fresh server and a migration. But if you can’t do that today, installing PHP 8 via Remi is the correct move. It gives you modern language features without breaking your OS foundation.
Installing common extensions
Bare php is rarely enough. You usually need specific extensions for your framework or application. Don’t guess which packages to install. Use these standard names:
sudo yum install php-cli php-fpm php-mysqlnd php-mbstring php-xml php-opcache
This covers the basics: the CLI, the FastCGI process manager, MySQL driver, multibyte string handling, XML support, and the OPcache for performance.
After installing extensions, check what is actually loaded. Run this to see the list:
php -m
If you see pdo_mysql, mbstring, and opcache in that list, you are good to go. If something is missing, install the specific package (e.g., sudo yum install php-pdo) and restart your web server.
Restarting your services
Installing PHP doesn’t automatically restart your web server. Your Apache or Nginx setup might still be pointing to the old binary or using a cached configuration.
If you are running PHP-FPM, restart it:
sudo systemctl restart php-fpm
If you are using mod_php with Apache, restart httpd:
sudo systemctl restart httpd
I always restart both just to be safe. It’s a one-second command that prevents 90% of “why isn’t this working” issues.
Troubleshooting: Wrong version showing up
This is the most common mistake I see. You run php -v and it still shows PHP 7.4 or 5.6. What happened?
You have multiple Remi repositories enabled. By default, none of the Remi PHP repositories are enabled. The usual cause is that another one (like remi-php74) was enabled earlier on that server. If remi-php74 and remi-php80 are both active, YUM gets confused about which binary to link as the system default.
Fix it by disabling all Remi PHP repos first:
sudo yum-config-manager --disable 'remi-php*'
Then enable only the one you want:
sudo yum-config-manager --enable remi-php80
Finally, update again to force the system to pick the correct binary:
sudo yum update
Now php -v will show the version you actually want. This step is critical if you are upgrading from an older PHP version on the same machine.
Pick a side
CentOS 7 is in maintenance mode, and PHP 8.0 is already end-of-life as of November 2023. If you are starting fresh, go to 8.3. If you are stuck on 7.4, move to 8.1 or 8.2. But if you are here, you need it working now.
Remi makes this easy. The commands above work. I’ve used them on dozens of servers. They are stable, fast, and get out of your way. Use them, restart your services, and move on to building the thing you actually care about.