PHP-7 for EasyApache3

The latest versions of cPanel come with EasyApache 4 which provides a lot of new features like PHP 7 support, native support for multiple PHP versions, etc. So it is recommended to migrate to EasyApache 4 to utilize these features. However, if you cannot migrate EasyApache 4 due to some reason (Example: Tomcat support), you will have to compile the PHP 7 manually from source to use it with EasyApache3.

PHP7 manual installation

Note: The PHP handler should be SuPHP to get this working.

1. Download the required PHP-7 distribution Go to site to find the latest version.
2. Unpack the downloaded file.
3. Now build it.

In order to compile PHP from source, you should provide the ./configure options and choose which modules do you want to install.

For example,

# ./configure –enable-bcmath –with-bz2 –enable-calendar –with-curl –enable-exif –enable-ftp –with-gd –with-jpeg-dir –with-png-dir –enable-gd-native-ttf –with-imap –with-imap-ssl –with-kerberos –enable-mbstring –with-mcrypt –with-mhash –with-mysql –with-mysqli –with-openssl –with-pdo-mysql –with-zlib-dir –with-regex –enable-sockets –with-xmlrpc –enable-zip –with-zlib –enable-mbregex –enable-fpm –prefix=/usr/local/php

The above command will enable basic extensions like ftp, GD, ftp, IMAP, PDO, MySQL etc

Then execute the below commands:

# make
# make install

4. After compiling from source, copy the default PHP configuration file to the installation directory.
5. Verify the installation:

# /usr/local/php70/bin/php -v
PHP 7.0.22 (cli) (built: Aug 5 2017 01:56:23) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22, Copyright (c) 1999-2017, by Zend Technologies

6. Now link our new PHP 7 installation with Apache web server by generating a new PHP config for PHP7 and adding handler to SuPHP.
7. Add our custom PHP configuration file to EasyApache list so that the changes will not be lost future in EasyApache builds.
8. Restart Apache.

You are done!

In order to configure your website to use PHP7, add the following code to the .htaccess file located within the site’s document root.

AddType application/x-httpd-php7 .php7 .php

Do note that the PHP handler should be SuPHP for the above steps to work.

If you require help, contact SupportPRO Server Admin

Server not running properly? Get A FREE Server Checkup By Expert Server Admins - $125 Value

Leave a Reply