Easy Apache 4 comes with 2 great features - PHP 7 out of the box and the ability to choose whichever version of PHP you want to run per virtual host.
To install EA4 run the command below as root:
Before you update, please check your
/etc/yum.conf file and make sure it has plugins=1 in it. Otherwise the build will fail.
If anything goes wrong during the upgrade process you can always go back with
/scripts/migrate_ea3_to_ea4 --revert --run
After the build has finished (it takes a while), go into WHM and provision this version: "All PHP Options + OpCache"
In this tutorial I want to share my experience with installing PHP7 on one of my WHM/cPanel driven servers on which I had multiple websites that simply couldn't run a version of PHP that is from this century.
I needed to have PHP 7 up and running for some websites and leave the old ones with the old version of PHP (5.3 I think).
Also I needed to do things in such a way that people would stil be able to update anything in cPanel/WHM ... basically make everything completely separate.
For background, you should know that I tested this on CENTOS 6.7 x86_64 kvm – main with WHM 11.52.1 (build 2).
After some research I had a plan in place so I went straight ahead and compiled PHP 7 from source. Here's how:
cd /usr/local/ mkdir php7.0 cd php7.0 wget http://php.net/distributions/php-7.0.1.tar.gz tar -xvf php-7.0.1.tar.gz cd php-7.0.1 # don't forget to run ./configure --help to see all available options first ./configure --enable-bcmath --enable-calendar --enable-exif --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-mbstring --enable-pdo=shared --enable-sockets --enable-zip --prefix=/usr/local/php70 --with-curl=/opt/curlssl/ --with-freetype-dir=/usr --with-gd --with-gettext --with-imap=/opt/php_with_imap_client/ --with-imap-ssl=/usr --with-jpeg-dir=/usr --with-kerberos --with-libdir=lib64 --with-libxml-dir=/opt/xml2/ --with-mcrypt=/opt/libmcrypt/ --with-mysqli --with-openssl=/usr --with-openssl-dir=/usr --with-pcre-regex=/opt/pcre --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-pic --with-png-dir=/usr --with-xpm-dir=/usr --with-zlib --with-zlib-dir=/usr make make test make install cd /usr/local/php70/bin ./php -v
If everything worked fine for you, running
./php -v in the
/usr/local/php70/bin folder should give you something like this:
PHP 7.0.1 (cli) (built: Dec 18 2015 03:53:53) ( NTS ) Copyright (c) 1997-2015 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
I only added a few basic extensions here and I relied on the "pre-made" php.ini sample file for production.
cp -f /usr/local/php7.0/php-7.0.1/php.ini-production /usr/local/php70/lib/php.ini echo "extension=pdo.so" >> /usr/local/php70/lib/php.ini echo "extension=pdo_mysql.so" >> /usr/local/php70/lib/php.ini echo "zend_extension=opcache.so" >> /usr/local/php70/lib/php.ini # if you need more specific configuration just open up the php.ini file end edit it.
At this point you can delete the
/usr/local/php7.0 folder (the source code)
We need to create a configuration file for apache in order to be able to add the php7 handler so, to do that, open up a new file:
/usr/local/apache/conf/php7.conf and paste the code below. Don't forget to modify the "Directory" path regex to suit your needs.
vi /usr/local/apache/conf/php7.conf <IfModule mod_suphp.c> <Directory ~ "home/user/public_html/"> AddType application/x-httpd-php7 .php suPHP_AddHandler application/x-httpd-php7 </Directory> </IfModule>
To create a new handler in supPHP ... open up suphp.conf:
/opt/suphp/etc/suphp.conf. Then add the new handler using the code below, at the end of the handlers list.
;Handler for php-scripts #... existing handlers are here ... put yours below them application/x-httpd-php7="php:/usr/local/php70/bin/php-cgi"
There are two options here. You either go into WHM and edit the post_virtualhost_global.conf file from there or you just run:
vi /usr/local/apache/conf/includes/post_virtualhost_global.conf. Add the line below in that file and you should be all done.
Now restart Apache and enjoy!
service httpd restart
The php7.conf file in /etc/httpd/conf/php7.conf should be kind-of like this:
<IfModule mod_suphp.c> <Directory ~ "home/something/something/"> AddType application/x-httpd-php7 .php suPHP_AddHandler application/x-httpd-php7 </Directory> </IfModule>
~ is for a Regular Expression so make sure it works.
b) The IfModule only loads the handler if
mod_suphp is enabled ... so if it doesn't load it is most likely not enabled. Try removing the
The /etc/httpd/conf/includes/post_virtualhost_global.conf should have the link to the above as the very last include:
Make sure that
/opt/suphp/etc/suphp.conf has this line:
Attention! If you are running Easy Apache 4,
suphp.conf is located in
/etc/suphp.conf so add your handler there.
* If the above doesn't help... I won't be able to help with more instructions unless I actually look at the server.
Can't remember your password ?
Reset it using the form below:
Fill the form below to create
an account with codepunker.com