Home > Article > Backend Development > How to install PHP7 on CentOS and RHEL
php7.3 is the latest stable version of php and the yum repository is providing RPM packages for php7. This article will use remi and epel-yum repositories to install the required packages on your system. It will introduce the installation of php 7.3, php 7.2, and php 7.1 on CentOS and Redhat7 servers.
Setting up the yum repository
First, the Remi and EPEL yum repositories need to be enabled on the system. Use the following command to install EPEL repository on CentOS and Red Hat 7/6 systems
Use this command to install EPEL yum repository on your system
$ sudo yum install epel-release
Now according to your operating system Execute one of the following commands to install the REMI repository.
$ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Installing php 7 on CentOS
Your system is ready to install PHP from the yum repository. Depending on your needs, use one of the following commands to install PHP 7.3, PHP 7.2 or PHP 7.1 on your system.
## Install PHP 7.3 $ yum --enablerepo=remi-php73 install php ## Install PHP 7.2 $ yum --enablerepo=remi-php72 install php ## Install PHP 7.1 $ yum --enablerepo=remi-php71 install php
It is assumed that the latest version of php 7.3 is already installed on the system. Now run the following command to check the PHP version currently running on your system.
$ php -v PHP 7.3.0 (cli) (built: Dec 4 2018 16:12:20) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
Installing PHP modules
You may also need to install other PHP modules based on your application needs. The following commands will install some of the more useful PHP modules.
### For PHP 7.3 $ yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt ### For PHP 7.2 $ yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt ### For PHP 7.1 $ yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt
You can run the following command to search for other available PHP modules under the configured yum repository. The example command below will search all modules for PHP 7.3.
$ yum --enablerepo=remi-php73 search php | grep php73 php73.x86_64 : Package that installs PHP 7.3 php73-php.x86_64 : PHP scripting language for creating dynamic web sites php73-php-bcmath.x86_64 : A module for PHP applications for using the bcmath php73-php-brotli.x86_64 : Brotli Extension for PHP php73-php-cli.x86_64 : Command-line interface for PHP php73-php-common.x86_64 : Common files for PHP php73-php-componere.x86_64 : Composing PHP classes at runtime php73-php-dba.x86_64 : A database abstraction layer module for PHP applications php73-php-dbg.x86_64 : The interactive PHP debugger php73-php-devel.x86_64 : Files needed for building PHP extensions php73-php-embedded.x86_64 : PHP library for embedding in applications php73-php-enchant.x86_64 : Enchant spelling extension for PHP applications php73-php-fpm.x86_64 : PHP FastCGI Process Manager php73-php-gd.x86_64 : A module for PHP applications for using the gd graphics ... ...
This article has ended here. For more exciting content, you can pay attention to the php video tutorial column of the PHP Chinese website! ! !
The above is the detailed content of How to install PHP7 on CentOS and RHEL. For more information, please follow other related articles on the PHP Chinese website!