Skip to Content

How to upgrade php to 7.2 on Centos

PHP upgrade instructions for centOS and amazon linux


Overview: This article details how to upgrade PHP on CentOS 7 and Amazon Linux. For CentOS 7, enable EPEL and Remi repos, install yum-utils, and install PHP 7.x. For CentOS 6, migrate to CentOS 7 and then upgrade PHP. On Amazon Linux, install amazon-linux-extras, enable PHP 7.4, and install PHP packages. Confirm the PHP version after installation.  


Run these commands in the terminal to upgrade PHP:

Step 1. Turn on EPEL repo

root@gateway:~#  yum install epel-release

Step 2. Turn on remi-repo

Step 3. Install yum-util packages
 

root@gateway:~#  yum install yum-utils -y

Step 4. Enable remi repo as per the desired php version

root@gateway:~#   yum-config-manager --enable remi-php72

root@gateway:~#   yum update

Step 5. Finally install php7.X  
 

root@gateway:~#   yum install php72


How to upgrade PHP to 7.2 on centos 6(migrate to a new Centos 7 box)?

 We do not recommend using Centos 6 as it is no longer supported by the Linux community with security patches, vulnerabilities, or bug fixes. You can follow the instructions to migrate to a centos 7 box and upgrade PHP in centos 7 after migration.

Follow the instruction to migrate to a new Centos 7 box

Step 1. Run the script /usr/local/sbin/backup_ezlogin.php on the current server to create the backup archive.The backup archive would be created in /var/ezlogin.xx.bin

root@Remote:~# /usr/local/sbin/backup_ezlogin.php

_ _
___ _______ ___| | ___ __ _(_)_ __
/ _ \_ / _ \/ _ \ |/ _ \ / _` | | '_ \
| __// / __/ __/ | (_) | (_| | | | | |
\___/___\___|\___|_|\___/ \__, |_|_| |_|
|___/


#########################
# Ezeelogin Backup #
#########################

Checking environment... The memory limit is less than 4 GB. If the script crashes abruptly without any errors, try increasing the PHP memory limit.
done


Based on your command line arguments, you may be prompted to enter the missing settings. The default value will be given in bold. Simply pressing enter key will choose the default value.
Creating directories... done
Copying files... done
Backup database... done
Backup logs... done
Creating executable archive... done

########################################################
Ezeelogin backup created: /var/ezlogin_backup_v7.37.11_b381_p8.2.20_Sat_Jul_20_2024_06_07_21_UTC.bin
(Log: /var/log/ezlogin_backup.log)
########################################################

For free assistance, please contact [email protected]

Thank you for choosing Ezeelogin.
www.ezeelogin.com

Step 2. Spin up a new Centos 7 Vm and make sure to install the exact version of the packages such as PHP, web server, PHP modules, ioncube, Mysql etc.

Step 3. Issue a temporary license for the new VM. Contact the Ezeelogin support team to issue a temporary license for migration with your public IP of new Centos VM.

wget -qO- http://ezeelogin.com/myip

Step 4. Move the executable ezlogin.xx.bin archive to the new Centos 7 server, and execute the .bin file.

root@oldserver:~# scp /path/to/ezlogin.xx.bin username@new- centos_server-ip:/destination/path/

Example:  root@oldserver:~# scp /var/ezlogin_backup_v7.37.11_b381_p8.2.20_Sat_Jul_20_2024_06_07_21_UTC.bin [email protected]:/root/

root@Centos:~# sh ezlogin.xx.bin

Example: root@Centos:~# sh ezlogin_backup_v7.37.11_b381_p8.2.20_Sat_Jul_20_2024_06_07_21_UTC.bin

Follow the on-screen instructions.

Step 5. You can migrate your production license to the new centos7 box after confirming that everything working on your new machine. You can contact the ezeelogin support team for license migration.

Step 6. You can follow the above instructions to upgrade PHP on Centos 7 and upgrade to PHP version to the latest version.


How to upgrade PHP in amazon-linux?

Step 1.  Install the amazon-linux-extras package 

[ec2-user:]$  sudo yum install -y amazon-linux-extras

Step 2. Confirm that PHP 7.x  is available in our Amazon Linux 2 machine

[ec2-user:]$  sudo amazon-linux-extras | grep php

Step 3. Enable php7.4 by running the following command: 

[ec2-user:]$  sudo amazon-linux-extras enable php7.4

Step 4. Install PHP packages from the repository.

[ec2-user:]$  sudo yum clean metadata

[ec2-user:]$   sudo yum install php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}

Step 5. Confirm the PHP Version

[ec2-user:]$  php -v 

PHP 7.4.5 (cli) (built: Apr 23 2020 00:10:21) ( NTS )
Copyright (c) The PHP Group 
Zend Engine v3.4.0, Copyright (c) Zend Technologies