Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Update to PHP 7.4 from PHP 7.x on CentOS 7

I'm running PHP 7.1 on CentOS 7 which was installed using Remi Repo. WordPress is informing me to update to PHP 7.4 for security reasons. How can I update the PHP version on the server running Apache/MySQL LAMP stack?

like image 344
raw-bin hood Avatar asked Jul 13 '20 06:07

raw-bin hood


People also ask

How do I update a specific version of PHP?

Scroll down to the Advanced settings tile and select PHP and database settings. Scroll down to Update PHP version. Select the PHP version you want to switch to and click Update.


1 Answers

READ FIRST -- IMPORTANT !!! Get a complete backup snapshot of your server before you complete these update steps

  1. First thing you should do is do any core OS updates and package updates.

    yum update -y

  2. Check which version of PHP you are currently running.

    php -v

  3. Print a list to see all the PHP packages you have installed. You will need to replace all these packages in PHP 7.4. You should copy this list to a file so you can refer to it if you need to. Make a note of the version of PHP here (7x or 7-x).

    rpm -qa | grep php

    rpm -qa | grep php > php_rpm.txt

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

    yum remove "php*" -y

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

    yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm

  6. Check out a list of all available remi packages (not-required)

    yum repolist remi-safe

7. Disable PHP 7.x and enable PHP 7.4 (Replace x with sub-version of your previously installed version noted above in step 3) and install any extra packages you want / need.

yum --disablerepo=remi-php7x --enablerepo=remi-php74 install php php-pdo php-fpm php-gd php-mbstring php-mysql php-curl php-mcrypt php-json -y
  1. Check the updated PHP version.

    php -v

  2. Restart Apache to use the newly installed PHP 7.4

    systemctl restart httpd

like image 167
raw-bin hood Avatar answered Oct 20 '22 00:10

raw-bin hood