Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Reinstall or Upgrade PHP on CentOS7/RHEL7

November 12, 2022
in Blog, Linux
0
ADVERTISEMENT

Table of Contents

Reinstalling PHP on CentOS/RHEL7

In some cases, you want to reinstall PHP on your CentOS 7 server for improve the security or just want to upgrade PHP to higher version.

Note Note: First and foremost, get the complete backup of your server and the website before proceeding further.

1. Check the version of the PHP that is currently running using php -v command:

# php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

2. List all the PHP extension you have installed into a file, so you can refer to it to install all those packages in PHP 7.4 in the next step.

rpm -qa | grep php > php_rpm.txt
# rpm -qa | grep php > php_rpm.txt
# cat php_rpm.txt
php-json-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-snmp-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-process-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
php-gd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64
....

3. Get the current configurations of PHP then back them up.

php --ini
# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/10-opcache.ini,
...

In our case, we need to backup php.ini and www.conf configuration files.

sudo cp /etc/php.ini php.ini.bak
sudo cp /etc/php-fpm.d/www.conf www.conf.bak
# ll
total 156
-rw-------. 1 root root  1626 Mar 25  2022 anaconda-ks.cfg
-rw-r--r--  1 root root 63252 Nov 11 20:11 php.ini.bak
-rw-r--r--  1 root root   516 Nov 11 20:10 php_rpm.txt
-rw-r--r--  1 root root 19485 Nov 11 20:12 www.conf.bak

4. Remove PHP and all the installed PHP extension packages.

sudo yum remove "php*" -y

5. Install the updated Remi repository if it is not already installed.

sudo yum update -y	
sudo yum install epel-release -y
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

6. Enable REMI PHP7.4 repository for CentOS.

sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php74	

7. Install the core and required PHP packages. You can also refer to step 2 for the previously required packages from the file php_rpm.txt.

sudo yum -y install php php-xxx

8. Once done, check the updated PHP version using php -v command:

# php -v
PHP 7.4.32 (cli) (built: Sep 28 2022 09:09:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Additional

If you’re using PHP with WordPress and Nginx. After reinstalling or upgrade PHP, don’t forget change require information in the file /etc/php-fpm.d/www.conf and /etc/php.ini.

ADVERTISEMENT
5/5 - (1 vote)
Previous Post

How to Install ImageMagick on CentOS Linux

Next Post

How to Install PHP 7.2 on Centos 7/RHEL 7

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory