Alright, now that we are done celebrating it's time to actually get this working.

As of December 2016, you can now install and enable PHP 7 and FPM using WHM's Easy Apache 4 UI. If you prefer to use cli / ssh, I've got you covered!

To utilize PHP 7 and PHP-FPM on cPanel 11.54 (54), you need to ensure that WHM is updated to the latest version, at this time that is WHM 54. Once you've updated WHM to version 54 you need to enable Easy Apache 4. Please note that EA4 is still in beta (as of March 1, 2016) and not yet considered to be "stable", but honestly, "stable" is boring and slow, I don't deal with any of that nonsense. To switch from EasyApache 3 to Easy Apache 4, run this command from the command line:

/scripts/migrate_ea3_to_ea4 --run

After you've converted the server to Easy Apache 4 you can use WHM's UI to run / configure the server, or you can use YUM to install the glorious PHP 7 packages that cPanel was kind enough to create for us. I ran an "rpm -qa | grep -i httpd" to get an idea of what I installed (because I sometimes don't note what I'm doing) Below is copypasta of what I have installed, some of this might already be installed on your own server, but who cares, it's a server, it will figure it out :) FYI, we are going to use Apache Event for this guide because it's better than prefork and worker and everyone else talks about Nginx, so yea.

Now it's time to make a few new directories under the cPanel account's /home/ directory, make sure to update permissions if you are doing this as root, both directories need to be owned by the cPanel user, not by root. Take note of these locations, we will be modifying some conf files later on.

Step number two or three, or whatever the f**k number we're on..: Change "listen = /home/$cpanel_user/run/php56-fpm.sock". Since we are using PHP 7 we need to update the location of the listen .sock file, simply replace "$cpanel_user" with the cPanel user name, and replace "php56-fpm.sock" with "php70-fpm.sock" because we aren't using that old, slow PHP, we are using the new hottness!

listen = /home/$cpanel_user/run/php70-fpm.sock

Step 3: Change listen.owner = $cpanel_user to the cPAnel user, leave the listen.group alone, it should be set to nobody.

Step 5: Change error log locations, and session file locations. If you don't update these locations PHP-FPM may complain about read / write permissions if your site / CMS uses sessions. The actual location of these directories doesn't matter too much, I chose to place them under the user's home directory, but really the session save path can be anywhere, just make sure the directory has permissions set for the cPanel user.

Step 11: Enjoy PHP 7! If something doesn't work right, maybe PHP 7 is not for you, but odds are, it is, and your website now runs faster. Good job, take a break, you deserve it. Unless you done goofed, in which case, enjoy the image below.

Login to your cPanel account and look under mail then spamassasin in cPanel.

TURN OFF AUTO DELETE

Have SpamAssassin send spam to a folder, or spam account instead of deleting messages. Until you have tested the scores out and make sure that good email actually gets through you should setup a temp email address, or a folder and have SpamAssassin send any "spam" there so you can later look through the folder or account to make sure you aren't deleting good emails.

Once you have enabled and configured SpamAssassin you will want to create another email account, or a new folder that will automatically receive any email that is flagged by SpamAssassin. Once you have done this you will want to create a filter that looks like below. This will make sure that email is not lost.

If you prefer to just send all email that is flagged as spam to a single address configure the filter to look like the image below. You could also set a Global Filter for all email accounts, this would make it easier to manage and if a single user is missing an email you can then login to the main spam account and look for the message there.

If you only want to manage spam for a single email address, this is the best method to use. Create a new folder called "SPAM" then create a user level filter that sends any email marked as spam to that folder.

Before you attempt to install PHP-FPM on a cpanel server, you will want to run EasyApache and make sure you un-select all Apache MPMs other than Event and ITK (If you have many vhosts and want better security). Make sure you select mod_fastcgi (FCGI) as well.

/scripts/easyapache

Once EA has finished you can download the script below and install PHP-FPM. You will want to backup httpd.conf before you run this in case anything gets messed up. I found that I needed to start php-fpm after the script finished, if you don't make sure it's started then your sites will more than likely be down until you do this.

I found that by switching to PHP-FPM and Apache Event I was able to shave off around 1 second from my main page loading time. Previously I was at around 4 seconds, now I am around 3 seconds, so there is a large performance with PHP-FPM

You can view and configure each pool by modifying the per domain config files located here:

/opt/xstack/cphstack/php-fpm.pool.d/*.conf

If you prefer to just use one global config file you can modify it here

vim /usr/local/etc/php-fpm.conf

If you want to use memcached you need to add the extension location in the main php-fpm.conf file. NOTE even if you have memcached listed as a php module (php -m) you must enable this specifically for php-fpm.

If you try to use git on a cpanel server and are unable to connect you will need to allow port 9418 in the firewall. If you use ConfigServer Security & Firewall you can edit this in WHM > Plugins > ConfigServer Security & Firewall. Then go to "Firewall Configuration" and allow port 9418.

If you have a cPanel server and already have PHP version 5.5 installed all you need to do is modify the main php.ini file and add in the lines below. Using Opcache can significantly improve PHP performance which means your website will run faster. If you have a large website I would suggest raising the opcache.memory_consumption value to something higher than 64 (mb).

The first step is to make sure you are using PHP 5.5. To check this run:

php -v

If you are not running PHP 5.5 then you will want to run EasyApache and upgrade PHP to 5.5.

/scripts/easyapache

Once you are running PHP 5.5 you will want to enable opcache by adding the lines below to your php.ini

DomainKeys Identified Mail (DKIM) defines a mechanism by which email messages can be cryptographically signed, permitting a signing domain to claim responsibility for the introduction of a message into the mail stream. Message recipients can verify the signature by querying the signer's domain directly to retrieve the appropriate public key, and thereby confirm that the message was attested to by a party in possession of the private key for the signing domain.

To verify that everything is setup correctly you can send an email from an email account on that domain to [email protected] No need to have a subject or body. This service will then reply with a message stating the verification of DKIM, DomainKeys, SPF, SpamAssassin, and Sender-ID. Great tool to test all kinds of email verification systems.

To install on a cPanel server:

/usr/local/cpanel/bin/dkim_keys_install <username>
or
for i in `ls /var/cpanel/users`; do /usr/local/cpanel/bin/dkim_keys_install $i; done

APF SMTP tweak enables mail to be sent only from the mail or mailman GID, and blocks all outbound SMTP, except through the sendmail binary.
Add this bold line of code to /etc/init.d/apf , right underneath the start) case:

You can enable compression for all content on your website by logging into your cPanel account and clicking on the "Optimize Website" button that is located near the bottom of the main cPanel page. The image below shows the Optimize section, which lets you disable compression, enable compression for ALL file types, or enable compression for specified MIME types like html, xml, or other text files. I chose to enable compression for everything just to see what would happen.

I installed WordPress and created a few posts with 1MB gif and jpeg images. I used GTmetrix and WebPageTest before and after enabling compression. I did notice a slight reduction in page size after I enable compression. I also received an A for PageSpeed and YSlow gzip compression after I enabled it in cPanel.

By default cPanel will create a .htaccess in /home/$your_user/

Once you enable compression for everything in cPanel the .htaccess file will look like this:

I highly suggest enabling compression for everything, if possible. It does certainly help to reduce website load time, as well as reducing the amount of bandwidth your server uses. Now that compression is enabled, you are one step closer to an optimize website! Make sure that you are enforcing Browser Caching for your website as well!

As of March 2015 and WHM 11.48, MariaDB is now officially built into WHM and fully supported. The installation steps below are no longer needed, but I'm keeping them around in case you are unable to upgrade WHM.

I've confirmed that this works without issue on WHM 11.44.1. I was able to run a forced upcp and easyapache, update WHM versions, update PHP versions, all without breaking anything in WHM, MariaDB remained online the whole time. Keep in mind that by doing this you are basically giving up any support from cPanel as they state that doing this is not supported. I am not sure if this would break or cause any issues for CloudLinux cPanel Servers but these instructions should be the same for CloudLinux and non CloudLinux versions of cPanel.

Step 1: If MySQL is still version 5.5 on cPanel, update MySQL to 5.6 before proceeding. Make sure to backup and databases before doing this. Once logged into WHM, you can upgrade MySQL by going to the following page.

Step 5: Create a new mariadb repo and add in some things. NOTE! Change the version "10.1" to whatever version you want to install. For the latest version use 10.1, but in the future this will obviously change.

vim /etc/yum.repos.d/MariaDB.repo
## Add this to the file, and then save / close it
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Step 6: Remove PHP and MySQL from the excludes line in the cPanel /etc/yum.conf file.

vim /etc/yum.conf
##remove the following items from the excludes line:
mysql*
php*

Step 7: Install the new MariaDB packages

yum install MariaDB-server MariaDB-client MariaDB-devel php-mysql

Step 8: Start MySQL, run the upgrade and restart MySQL

/etc/init.d/mysql start
mysql_upgrade
/etc/init.d/mysql restart

Step 9: At this point MySQL should be running and the existing databases should be in tact. However now is a great time to make sure this is the case:

Step 10: If all looks well with MySQL, then run easyapache to make sure everything is working and cPanel isn't totally broke

screen -S isitbroke
/scripts/easyapache --build

Step 11: At this point the easyapache build should have completed without error. I tested this install out on a brand new cPanel server and can confirm that PHP does indeed work just fine after this install process. I can also confirm that ea works, even when updating PHP versions or adding new modules.