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.  


1. Upgrade PHP in CentOS 7:

Step 1(A): Turn on EPEL repo

:~# yum install epel-release

Step 1(B): Turn on remi-repo

Step 1(C): Install yum-util packages
 

:~#  yum install yum-utils -y

Step 1(D): Enable remi repo as per the desired php version

:~# yum-config-manager --enable remi-php72

:~# yum update

Step 1(E): Finally install php7.X  
 

:~# yum install php72


2. How to migrate Ezeelogin to a new Centos 7 box?

Note: 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 2(A): Run the script /usr/local/sbin/backup_ezlogin.php on the current gateway server to create the backup archive.The backup archive would be created in /var/ezlogin.xx.bin

:~# /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(B): 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 2(C): 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 2(D): Move the executable ezlogin.xx.bin archive from old server to the new Centos 7 server.

:~# scp /path/to/ezlogin.xx.bin username@new_centos_server_ip:/destination/path/

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

Step 2(E): Execute the .bin file in the new server.

:~# sh ezlogin.xx.bin

Example: 
:~# 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 2(F): You can migrate your production license to the new centos7 box after confirming that everything is working on your new machine. You can contact the ezeelogin support team for license migration.

Step 2(G): After migrating Ezeelogin to the new machine, follow the steps to upgrade PHP in cnetOS 7.


3. How to upgrade PHP in amazon-linux?

Step 3(A):  Install the amazon-linux-extras package 

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

Step 3(B): Confirm that PHP 7.x  is available in our Amazon Linux 2 machine

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

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

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

Step 3(D): 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 3(E): 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