Install PHP7 on CentOS7 or RHEL7

Install PHP7 on CentOS7

In this article, we will review how to Install PHP7 on CentOS7 or RHEL7, empowering you to harness the speed, efficiency, and enhanced features of the latest PHP version for your web development projects.

Table of Contents

Introduction

PHP7, the latest major release of the PHP programming language, brings significant improvements in performance, memory usage, and error handling over its predecessors. Installing PHP7 on CentOS7 or Red Hat Enterprise Linux (RHEL7) allows users to take advantage of these enhancements while ensuring compatibility with their existing server environments.

PHP7 was officially released on December 3, 2015, marking a major milestone in the evolution of PHP. It introduced a plethora of new features and optimizations, including a new Zend Engine (Zend Engine 3.0), which significantly improved performance compared to PHP 5.x versions.

Before we begin

CentOS 7 Installation: Make sure your system runs a fresh CentOS 7 installation. Obtain the CentOS 7 ISO from the official website and adhere to the installation guidelines to configure your system.

Root Access: You must possess root or sudo privileges for installing packages and implementing system-level alterations. If you’re not currently logged in as root, ensure you possess sudo privileges to execute commands.

Internet Connectivity:Confirm that your CentOS 7 system is connected to the internet, as you’ll need to fetch packages from the repositories during the installation phase.

Important: CentOS 7 will reach its end-of-life in June 2024. Plan to transition to a supported version before this date.

Update your machine

Start by ensuring your server’s operating system is up-to-date. Run the following command to update the package repositories and install any available updates:

				
					$ sudo yum update -y
				
			

Enable Additional Repositories

PHP7 packages are not included in the default CentOS7 or RHEL7 repositories. You’ll need to enable additional repositories like Remi to access PHP7 packages. Use the following commands to enable the Remi repository:

				
					$ sudo yum install epel-release yum-utils

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

Install PHP7 on CentOS7 or RHEL7: Installation Procedure

Follow these steps (below) to install PHP7 on your CentOS7 or RHEL7 machine.

Choose PHP Version

Decide which version of PHP7 you want to install. The Remi repository provides multiple versions of PHP7, including the latest stable release and older versions for compatibility purposes. For example, to choose a PHP version 7.4, run the following command:

				
					$ sudo yum-config-manager --enable remi-php74
				
			

Verify that the PHP 7.4 repository is enabled:

				
					$ yum repolist enabled | grep remi-php74
				
			

Install PHP7 on CentOS7 or RHEL7: Install PHP-7.4

Run the following command to install PHP-7.4 and its necessary dependencies:

				
					$ sudo yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
				
			

Verify the PHP version

Verify the right PHP version is installed by running this command:

				
					$ php -v

PHP 7.4.27 (cli) (built: Dec 14 2021 17:17:06) ( NTS ) 
Copyright (c) The PHP Group 
Zend Engine v3.4.0, Copyright (c) Zend Technologies 
   with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
				
			

This example demonstrates how to install PHP-7.4 from the Remi repository on CentOS7. Make sure to adjust the package names and commands according to your specific requirements (PHP version) and preferences.

Conclusion

Upgrading your CentOS7 server or RHEL7 server to PHP-7.4 from the Remi repository opens up a world of possibilities for enhancing the performance and functionality of your web applications. By following the steps outlined in this guide, you can seamlessly transition to PHP-7.4, taking advantage of its improved speed, efficiency, and feature set.

Did you find this article useful? Your feedback is invaluable to us! Please feel free to share your thoughts in the comments section below.

Related Posts

Install MariaDB on CentOS7
Commands
Install MariaDB on CentOS7

In this step-by-step guide, we will show you how to install mariaDB on CentOS7. MariaDB is a fork of MySQL relational database management systems (RDBMS). Table

Read More »

Leave a Reply

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