PHP

Upgrading PHP 7.4 to PHP 8.1 in CentOS 7

CK CK 3788 
Created at
Updated at  
641 0 0

If you have both PHP 7.4 and PHP 8.1 installed on CentOS 7, but you're unsure where PHP 8.1 is located (e.g., for CLI use or configuring services), you can locate it with the following steps:

 

1. Check Current PHP Version

php -v

 

2. Install EPEL and Remi Repositories

sudo yum install epel-release yum-utils -y
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y

 

3. Enable Remi PHP 8 Repository

First, check available PHP modules:

yum module list php

Enable PHP 8.1 (or 8.2 if needed — change version accordingly):

sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81

 

4. Upgrade PHP

sudo yum update -y
sudo yum install php php-cli php-common php-fpm php-mysqlnd php-xml php-mbstring php-opcache php-json php-gd php-curl -y

(Add any other PHP extensions your application needs)

 

5. Verify PHP Version

php -v

 

6. Restart Web Server

For Apache:

sudo systemctl restart httpd

For Nginx with PHP-FPM:

sudo systemctl restart php-fpm
sudo systemctl restart nginx

 

 

In my case, I faced following errors while installing PHP 8.1

Error: Package: php-pecl-redis5-5.3.7-2.el7.remi.7.4.x86_64 (@remi-php74)
           Requires: php(api) = 20190902-64
           Removing: php-common-7.4.33-15.el7.remi.x86_64 (@remi-php74)
               php(api) = 20190902-64
           Updated By: php-common-8.1.29-1.el7.remi.x86_64 (remi-php81)
               php(api) = 20210902-64
           Available: php-common-8.1.28-1.el7.remi.x86_64 (remi-php81)
               php(api) = 20210902-64
Error: Package: php-pecl-redis5-5.3.7-2.el7.remi.7.4.x86_64 (@remi-php74)
           Requires: php(zend-abi) = 20190902-64
           Removing: php-common-7.4.33-15.el7.remi.x86_64 (@remi-php74)
               php(zend-abi) = 20190902-64
           Updated By: php-common-8.1.29-1.el7.remi.x86_64 (remi-php81)
               php(zend-abi) = 20210902-64
           Available: php-common-8.1.28-1.el7.remi.x86_64 (remi-php81)
               php(zend-abi) = 20210902-64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

 

And the solution was to remove the PHP 7.4-specific packages such as php-pecl-redis5 before processing with the PHP 8.1 upgrade.

 

Below steps are what I did:

1. Remove the PHP 7.4 Redis extension:

 

sudo yum remove php-pecl-redis5

 

2. Then upgrade PHP to 8.1:

sudo yum install php php-common php-cli php-fpm php-mbstring php-xml php-mysqlnd php-opcache php-gd php-curl

 

3. Reinstall Redis for PHP 8.1:

Install the compatible php-pecl-redis version from the Remi PHP 8.1 repo:

sudo yum install php-pecl-redis

It will pull the correct version (e.g., php-pecl-redis-5.x or 6.x) compiled for PHP 8.1.

 

📌 Notes

  • php(api) and php(zend-abi) are version-specific. They must match exactly for extensions to work.
  • Use yum list installed | grep php to see what 7.4 packages are still lingering.
Tags CentOS 7 PHP 7.4 PHP 8.1 PHP Upgrade Redis php-pecl-redis Facebook X
Comments 0
Similar posts
  1. The Ultimate Data Engineering Roadmap
    1,069
  2. Using Queue Algorithm with Redis - RPUSH and LPOP
    767
  3. Installing Python 3.8 in a venv environment on CentOS 7
    460
  4. Redis vs Memcached: Why Enterprise Tech Giants Choose Redis
    247
  5. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  6. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  7. Set up an SMTP server on CentOS 7
    724
  8. Large-Scale Concurrency Control: Solving the DB Bottleneck from a Flood of “Likes”
    268
  1. When you Postgresql Module is not able to open connection : Doubt your libpq version
    472
  2. How to Get a YouTube Channel ID from a URL in PHP
    1,014
  3. Building a MCP server in PHP
    626
  4. PHP 7 vs PHP 8
    1,240
  5. gRPC Server with PHP
    499
  6. PHP Code to Fetch current Coinbase Assets (Balances)
    437
  7. PHP Code to Fetch PEPE coin pricing based in USD from Coinbase
    362
  8. Google Single Sign-On implementation with PHP
    1,367
  9. PHP Superglobal Variables do not require additional syntax to access it
    2,617
  10. Run Python Code with Virtual Environment in PHP
    671
  11. PHP Simplified Operators
    317
  12. PHP Heredoc (aka Nowdoc)
    427
  13. PHP Post Processing by disconnecting HTTP connection and continuing the remaining logics
    1,800
  14. WordPress Remote Posting with PHP
    1,675
  15. Google BigQuery Example to converted Nested FIelds in JSON
    458
  16. Verifying Apple In-App Purchase validation receipt with PHP
    1,779
  17. Useful code for file-based Unit Test in PHP
    498
  18. Function Overloading Implementation in PHP with Magic Mathods
    1,752
  19. PHP Magic - the Null Coalescing Operator (??) - return the value if the give variable is NULL
    1,666
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,703
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    197
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    508
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    232
  17. The Concept of Scaffolding in AI Agents
    221
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    575
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    252
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    326
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252