13

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?

Paulo Boaventura
  • 1,365
  • 1
  • 9
  • 29
raw-bin hood
  • 5,839
  • 6
  • 31
  • 45
  • To install PHP LEMP, follow the steps [https://stackoverflow.com/questions/56198160/how-do-i-change-the-default-php-base-version-on-shell](https://stackoverflow.com/questions/56198160/how-do-i-change-the-default-php-base-version-on-shell) – Paulo Boaventura Nov 15 '20 at 02:38

1 Answers1

36

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

raw-bin hood
  • 5,839
  • 6
  • 31
  • 45
  • 7
    Or simply follow the wizard instructions... https://rpms.remirepo.net/wizard/ – Remi Collet Jul 13 '20 at 12:28
  • That doesn't seem to remove any existing version of PHP that you have installed, which the OP question includes. – raw-bin hood Jul 13 '20 at 20:06
  • 1
    Of course, the yum update will update all installed packages... so ne need to remove anything. – Remi Collet Jul 14 '20 at 05:31
  • 2
    Jonnys guide is definitely helpful, if you previously installed PHP through a different repo, such as Webtatic because they don't use the standard naming convention. In this case removing the old PHP packages is necessary. If you are just upgrading within the same repo (remi), removing old packages would not be necessary. – C.Felix Oct 20 '20 at 08:08
  • I used the wizard, worked like a charm – GeneralCan Sep 26 '22 at 19:00