• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install PHP 7.3, 7.2, 7.1 on CentOS 7

Written by Admin, Updated On May 7, 2019
centos, php
How to Install PHP 7 on CentOS

PHP is a popular server-side scripting language and widely used for creating interactive and dynamic web pages. PHP 7.3 is the latest stable version of PHP. We will use EPEL and Remi repository to install PHP 7 on CentOS 7 server.

Installing PHP 7 on CentOS 7#

In this tutorial, we will show you how to install PHP 7.3, PHP 7.2 or PHP 7.1 on CentOS 7 system.

Prerequisites#

The user you are logged in as must have sudo privileges enabled to be able to install packages.

Configure Yum Repository#

At first, you have to install and enable EPEL and Remi yum repository on your CentOS 7 server. Run the below commands to install and enable EPEL and Remi yum repository.

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Now we are going to install yum-utils. It is a collection of useful programs for managing yum repositories and packages. It has tools that improve yum’s default features.

sudo yum install yum-utils

Next, we wil use yum-config-manager program which is included in yum-utils. We will use it to enable Remi repository as the default repository for installing different PHP versions.

Now you can install latest stable version of PHP on your server. Run the following commands to install PHP 7 on CentOS 7 server.

First choose specific php version of your choice and enable appropriate Remi repository for install PHP 7 as below:

For PHP 7.3
sudo yum-config-manager --enable remi-php73

For PHP 7.2
sudo yum-config-manager --enable remi-php72

For PHP 7.1
sudo yum-config-manager --enable remi-php71

After that, install PHP 7 with additional necessary modules which can extend the core functionality. Run below command:

sudo yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

Now, PHP is installed with specific version. Afterwards, you can check the installed PHP version.

Verify PHP Installation#

You can check installed PHP version using command line by type:

sudo php -v

It will show you output as below:

PHP 7.3.1 (cli) (built: Jan  8 2019 13:55:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.1, Copyright (c) 1999-2018, by Zend Technologies

In order to test verify that your system is configured properly for PHP, create a very basic PHP script called info.php file.

So create this file at web root of server. In CentOS 7 directory is located at /var/www/html/ so create file here by executing this command :

sudo nano /var/www/html/info.php

Add the following PHP code inside the file:

<?php
phpinfo();
?>

At last, Save and close file. Now visit this page in web browser using your server’s public IP address as following :

http://YOUR_SERVER_IP/info.php

It should show as following screenshot:

CentOS PHP info Page

Conclusion#

You learned how to install specific version of PHP 7 on CentOS 7 Linux server. You can send us any questions or additional thoughts by leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Apache on CentOS 7 Server
Next Article   How to Set Up Apache Virtual Hosts on CentOS 7

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install PHP 8.2 on Debian 11

    How to Install PHP 8.2 on Debian 11 Linux

    February 24, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook