How to add PHP7 support in cPanel via command line

PHP7 support is the dream of every developer and admins. Earlier for php7, we needed to use either cloudlinux or 1H tools.

The newer version of cPanel comes with a new version of easyapache. It comes with a lot of features and the main one is the use of RPMs.  By using RPMs, cPanel have made updating and installing a PHP module or apache module fast. Another advantage of easyapache4 is that it supports multiple versions of PHP. 

Here in this article I am discussing how to add php7 support via command line in a cPanel server. I am assuming that you are on the easyapache 4 and if you are not, you need to convert from easy apache 3 to easy apache 4  as per this instructions. 

Step 1 

Update WHM to the latest 

/scripts/upcp --force 

Step 2 

Install cPanel Apache 

yum install ea-apache24-mod_deflate ea-apache24-mod_ssl ea-apache24-mod_proxy ea-apache24-mod_mpm_event ea-apache24-tools ea-apache24-mod_proxy_http ea-apache24-mod_expires ea-apache24-mod_socache_memcache ea-apache24-mod_proxy_fcgi ea-apache24 ea apache24-mod_suphp ea-apache24-mod_cgid ea-apache24-config-runtime ea-apache24-mod_suexec 

Install cPanel PHP7 

yum install ea-php70-php-curl ea-php70 ea-php70-runtime ea-php70-php-mbstring ea-php70-php-mcrypt ea-php70-php-cli ea-php70-php-zip ea-php70-php-odbc ea-php70-php-pdo ea-php70-php-opcache ea-php-cli ea-php70-php-common ea-php70-php-mysqlnd ea-php70-php-soap ea-php70-php-fpm ea-php70-php-gd ea-php70-php-iconv

Now you need to add this line to the .htaccess file of each site to convert the site to php7 

<IfModule mime_module>
AddType application/x-httpd-ea-php70 .php .php5 .phtml
</IfModule>

Leave a Reply

Close Menu