After you have CentOS 7 installed inside your virtual machine or cloud server, you might be need to run web application software. Of course, to run web aplication on your virtual machine you need PHP and web server like Apache/HTTPD or Nginx. PHP stand for Hypertext Preprocessor, open source scripting language that is most widely used in website development.

Well, CentOS 7 server edition come with PHP 5.4 as their standard PHP version and it’s nood good, since PHP 5.4 has reached its End Of Life (EOL) since September 14, 2015. So, we need at least PHP 7.3 or PHP 7.4 to get full benefits of enhanced features and security patch from PHP.

To install PHP 7.4 on CentOS 7, simply follow this guide.

1.) Install Some Important Packages

If you have CentOS 7 minimal installation, you need to install some packages firts.

$ yum install wget telnet curl screen nano

2.) Install EPEL and Remi Repository for CentOS 7

$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
$ rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

3.) Update System Software and Packages

$ yum update

4.) Setting Up PHP 7.4 for Nginx + PHP-FPM or Apache/HTTPD Web Server

  • Configuring PHP 7.4 with FastCGI Process Manager “FPM” (generally to run with Nginx web server)
$ yum --enablerepo=remi-php74 install php-cli php-common php-gd php-imap php-mbstring php-mcrypt php-mysqlnd php-pdo php-soap php-tidy php-xml php-xmlrpc php-pecl-apc php-opcache php-fpm php-curl php-pear php-sqlite php-xsl php-gmp php-devel
$ systemctl enable php-fpm.service
$ systemctl start php-fpm.service
  • Configuring PHP 7.4 for Apache web server with mod_cgi or something like that (if you are using Apache/HTTPD)
$ yum --enablerepo=remi-php74 install php php-cli php-common php-gd php-imap php-mbstring php-mcrypt php-mysqlnd php-pdo php-soap php-tidy php-xml php-xmlrpc php-pecl-apc php-opcache php-curl php-pear php-sqlite php-xsl php-gmp php-devel
$ service httpd restart

5.) Let’s Check PHP Version

$ php -v
PHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
     With Zend OPcache v7.4.6, Copyright (c), by Zend Technologies

LEAVE A REPLY

Please enter your comment!
Please enter your name here