Enable gzip compression in cPanel

Using gzip compression allows you to deliver website content faster as it can be gzipped on the server and uncompressed on the client, reducing the file size you need to transfer.

Unfortunately mod_deflate, the Apache module required to do this, is not enabled on all cPanel installs. However, if it is, or you have access to the server, you can easily enable it.

Enabling mod_deflate

If you do not have mod_deflate, you need to use EasyApache to add it. Log in to Web Host Manager and go to EasyApache (only server admins will be able to do this). Select build from the previous configuration and customise it until you get to the exhaustive options list.

Check the box next to mod_deflate and then re-build Apache.

Enabling compression

Once you have mod_deflate enabled, cPanel will have a new option. Under “software and services” in the x3 skin you fill find an option called “optimise website”. Click through to that page.

Compress content will probably be set to “disabled”.

Select “Compress the specified MIME types” instead. You could enable it for all content but I would not recommend this as some content you will not want to compress and much of it (images for example) is pretty pointless. The third option allows you to customise.

By default it should have the following options:

text/html text/plain text/xml

I recommend adding some more:

text/html text/plain text/xml text/css text/javascript

Hit “update settings” and you are done!

Symlink Git on cPanel

These days cPanel comes with Git. However, it is not available as a command by default but is instead hidden away in cPanel’s usual obscure location.

However, you can make it accessible using a symlink.

ln -s /usr/local/cpanel/3rdparty/bin/git /usr/local/bin/git

That will allow you to use the git command as normal. The version you get is likely to behind the current version of Git though.

cPanel certificates expiring

If you use self-signed certificates on cPanel and WHM, they will still expire each year. You may find yourself getting an email such as:

The SSL certificate for ftp on host.example.com will expire in less than 30 days.

Your server’s SSL certificate for ftp will expire in less than 30 days. You need to install a new certificate as soon as possible. You can install a new certificate using WHM’s “Manage Service SSL Certificates” interface: https://host.example.com:2087/scripts2/manageservicecrts (Main >> Service Configuration >> Manage Service SSL Certificates).

To resolve this, click the link as suggested by the email. Then, next to each service, click “Reset Certificate”. This will generate a fresh certificate and automatically install it.

Installing Mongo PHP driver on CentOS 6 cPanel

Once again, the PECL installer. In order to get the Mongo driver for PHP working, you need to install it manually.

mkdir mongo
cd mongo
wget https://github.com/mongodb/mongo-php-driver/zipball/master
unzip master
cd mongodb-mongo-php-driver-df8b217
phpize
./configure
make install

Add the extension to your php.ini file.

extension=mongo.so

Restart Apache, and Mongo should appear inf your phpinfo() output.

Install Memcache on CentOS 6 cPanel

Here is how to install Memcache for PHP on a CentOS 6 cPanel / WHM box. Some of the guides suggest that you need libevent (well, you do need libevent), though when I tried it, I already had it installed. But if you need it, yum will sort you out.

yum install libevent

Next, install memcache itself. Note that the package is called memcached.

yum install memcached

Of course, just installing it doesn’t mean that the daemon is running. So don’t forget to start it too!

/etc/init.d/memcached start

Finally, we need to add the PHP extension. Beware that the PECL installer on WHM won’t work! So you need to compile it manually from source. That isn’t too difficult though.

wget http://pecl.php.net/get/memcache
tar zxvf memcache
cd memcache-3.0.6
phpize
./configure
make
make install

And add the extension to your php.ini.

extension=memcache.so

Now restart Apache and a memcache section should appear in your PHP info.

Installing Git on CentOS 5 cPanel

Following on from my previous post about installing Git on CentOS 4, CentOS 5 is a whole different story. This is because you actually can get the RPM for Git on Cent OS – but cPanel doesn’t make it quite easy enough to do it.

You see, cPanel likes to take control of a lot of it’s own stuff, so it has a long list of packages which it won’t update automatically, because it will end up breaking itself if it does. As Git has two dependencies from the Perl libraries, this causes a problem.

But we can easily fix that.

cd /etc/
vim yum.conf

Remove perl* from the exclude line, then save the file. Now you should be able to run the command.

yum install git

It will gather all the dependencies and install Git. Final step, go back into the YUM configuration and put the exclude pack in to protect cPanel from its malevolent self.

vim yum.conf

Installing Git on CentOS 4 cPanel

If you’re trying to install Git on CentOS with cPanel, you’ll probably be running into the problems where you can’t get hold the RPM because cPanel excludes all Perl modules. But that is a whole different problem to if you are running CentOS 4.

CentOS 4 doesn’t actually have the RPMs for Git at all. But luckily, it’s actually really easy to install on a cPanel server because cPanel should come will all the dependencies you need.

So, all you need to do is head over to the Git website, download the latest source (I tried it with v1.7.8.1) and compile it – no problems, no worries.

wget http://git-core.googlecode.com/files/git-1.7.8.1.tar.gz
tar xvzf git-1.7.8.1.tar.gz
cd git-1.7.8.1
./configure
make
make install