How to Install PHP 7.3 in CentOS 7

The CentOS 7 official software repositories have PHP 5.4 which has reached the end of life and no longer actively maintained by the developers.

To keep up with the latest features and security updates, you need a newer (probably the latest) version of PHP on your CentOS 7 system.

For the purpose of this guide, we will be operating the system as root, if that is not the case for you, make use of the sudo command to acquire root privileges.

Installing PHP 7 on CentOS 7

1. To install PHP 7, you have to install and enable EPEL and Remi repository on your CentOS 7 system with the commands below.

# yum install
# yum install

2. Next, you need to install yum-utils, a collection of useful programs for managing yum repositories and packages. It has tools that basically extend yum’s default features.

It can be used for managing (enabling or disabling) yum repositories as well as packages without any manual configuration and so much more.

# yum install yum-utils

3. One of the programs provided by yum-utils is yum-config-manager, which you can use to enable Remi repository as the default repository for installing different PHP versions as shown.

# yum-config-manager --enable remi-php70   [Install PHP 7.0]

If you want to install PHP 7.1, PHP 7.2 or PHP 7.3 on CentOS 7, just enable it as shown.

# yum-config-manager --enable remi-php71   [Install PHP 7.1]
# yum-config-manager --enable remi-php72   [Install PHP 7.2]
# yum-config-manager --enable remi-php73   [Install PHP 7.3]

4. Now install PHP 7 with all necessary modules with the command below.

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

Afterwards, double check the installed version of PHP on your system.

# php -v
Check PHP Version in CentOS 7

Check PHP Version in CentOS 7

Lastly, below is a list of useful PHP articles that you can read for additional information:

  1. How to Use and Execute PHP Codes in Linux Command Line
  2. How to Find MySQL, PHP and Apache Configuration Files
  3. How to Test PHP MySQL Database Connection Using Script
  4. How to Run PHP Script as Normal User with Cron

In this article, we have explained how to install PHP 7 on CentOS 7 Linux. You can send us any questions or additional thoughts via the feedback form below.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Aaron Kili

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

25 Responses

  1. Vince says:

    Thank you so much for your great article.

    I’m installing two PHP version 5.6 and 7, but when I enter php -v, it seems it only show 5.6. How can I use both of them?

    • Aaron Kili says:


      You can only view one PHP version on the command line, which is the default version. But you can run different sites using different PHP versions, which requires some configurations.

  2. Astarte says:

    Thank you so much it works perfectly ~ ^^

  3. Muhammed Yılmaz says:

    Thank you very much

  4. Roy says:

    I have a question, I did this on my VPS to work with php 7.1 for laravel. After everything went good, all my wordpress websites got an 502 gateway error. I immediately got the backup restored and got my sites back, but now the PHP version is back to the old 5.6.3 which is to low for my laravel thing.

    Is there any solution?

  5. sonia says:

    How to drop php 5.4?

  6. Yanni says:

    Many thanks

  7. Bao Nam says:

    thank you so much

  8. Olin says:

    Thank you for your guides.

    You may want to clarify that this guide is for CentOS 7 without any PHP installed, and not an upgrade from PHP 5.4. Unfortunately, this article didn’t work for me, as I have CentOS 7.4.1708 with PHP 5.4.16 already installed.

  9. Kirill says:

    Thanks so much..

  10. yodle says:

    what about php-fpm ? to configure with nginx ?

Got something to say? Join the discussion.

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.