How to install MariaDB Server in cPanel/WHM servers

MariaDB is a binary drop in replacement of the same MySQL version (for example MySQL 5.1 -> MariaDB 5.1, MariaDB 5.2 & MariaDB 5.3 are compatible. MySQL 5.5 will be compatible with MariaDB 5.5). What this means is that:

  • Data and table definition files (.frm) files are binary compatible.
  • All client APIs, protocols and structs are identical. All filenames, binaries, paths, ports, sockets, and etc… should be the same.
  • All MySQL connectors (PHP, Perl, Python, Java, .NET, MyODBC, Ruby, MySQL C connector etc) work unchanged with MariaDB.
  • The mysql-client package also works with MariaDB server.
  • The shared client library is binary compatible with MySQL’s client library.

This means that for most cases, you can just uninstall MySQL and install MariaDB and you are good to go. (No need to convert any datafiles if you use same main version, like 5.1). You must however still run mysql_upgrade to finish the upgrade. This is needed to ensure that your mysql privilege and event tables are updated with the new fields MariaDB uses. MariaDB do a monthly merges with the MySQL code base to ensure its compatibility and get any and all features and bug fixes Oracle adds.

There are some installation issues with PHP5 that you should be aware of ( REF: )

What are the advantages of using MariaDB Server ?

  • Faster and safer replication: Group commit for the binary log. This makes many setups that uses replication and lot’s of updates more than 2x times faster.
  • Indexes for the MEMORY(HEAP) engine are faster. According to a simple test, 24% faster on INSERT for integer index and 60% faster for index on a CHAR(20) column.
  • CHECKSUM TABLE is faster.
  • MariaDB improved the performance of character set conversions (and removed conversions when they were not really needed). Overall speed improvement is 1-5 % (according to sql-bench) but can be higher for big results sets with all characters between 0x00-0x7f.
  • Pool of Threads in MariaDB 5.1 and even better in MariaDB 5.5. This allows MariaDB to run with 200,000+ connections and with a notable speed improvement when using many connections.
  • There are some improvements to the DBUG code to make its execution faster when debug is compiled in but not used.
  • Our use of the Aria storage engine enables faster complex queries (queries which normally use disk-based temporary tables). The Aria storage engine is used for internal temporary tables, which should give a speed up when doing complex selects. Aria is usually faster for temporary tables when compared to MyISAM because Aria caches row data in memory and normally doesn’t have to write the temporary rows to disk.
  • The test suite has been extended and now runs much faster than before, even though it tests more things.

How can you replace MySQL with MariaDB Server in cPanel installed systems ?

Below you will find some steps on how to affectively stop cPanel/WHM from maintaining MySQL and begin utilizing MariaDB for any and all database activity on your server. MariaDB is “An enhanced, drop-in replacement for MySQL” (Source: .

We recommend only experienced systems administrators perform the above and we are not responsible for any possible data loss.

Step 1: Backup existing MySQL data

Make sure to save all existing data just in case there are any issues.

# mysqldump --all-databases --routines --triggers > /home/db_dump/alldb.sql
# service mysql stop
# cp -r /var/lib/mysql/mysql /home/db_dump/
# service mysql start
Step 2: Disable the targets so cPanel no longer handles MySQL updates #ONLY FOR cPanel 11.36+

The following will mark the versions of MySQL we distribute as uninstalled so they are no longer maintained by cPanel/WHM

# /scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
# /scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
# /scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled
Step 3: Remove existing MySQL RPM’s so theres a clean slate for MariaDB

Important: The below command will uninstall the MySQL RPM’s!

# /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55
Step 4: Create a yum repository for MariaDB

Access and select the DISTRO and place the repo content to /etc/yum.repos.d/MariaDB.repo

#nano /etc/yum.repos.d/MariaDB.repo

# MariaDB 5.5 CentOS repository list - created 2013-06-23 21:13 UTC
name = MariaDB
baseurl =

Step 5: install MariaDB using the following command
# yum install MariaDB-server MariaDB-client MariaDB-devel

If you are having any dependency problem, please remove PHP from the /etc/yum.conf file and then run yum command again. Please add it back to yum conf once the package is installed.

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

Please make sure to add PHP back to exclude section of /etc/yum.conf file.

Final Step: Rebuild Easyapache/PHP to ensure modules are intact/working
# /scripts/easyapache --build

Done !

How To Install PHP 5.2 on cPanel/WHM 11.40+

cPanel, Inc. has released EasyApache 3.24. This version removes Apache 1.3/2.0, PHP 5.2, and mod_frontpage. As mentioned in
Introducing EasyApachea Optimal Profiles, These End of Life (EOL) items are no longer available in EasyApache.

These items have been removed for the following reasons:

  • They are no longer supported by their respective developers.
  • They include unpatched CVEs (Common Vulnerabilities and Exposures).
  • EasyApache provides the most up-to-date, supported versions of Apache (2.2/2.4) and PHP (5.4/5.5).

Keep in mind that viable alternatives to mod_frontpage exist, such as WebDAV and FTP. Also, PHP 5.2 and mod_frontpage are available as custom modules (“opt mods”).

You can read more about how to use and install Custom Modules at :

Downgrading PHP version is not a good idea.We always suggest you to use latest updates version of software/Scripts you are using.In new cPanel version they have completely dropped support for PHP version 5.2 .If you PHP is corrupted or need to recompile it for some reason then you can’t rebuild your old PHP version using EasyApache (3.24) .So you may have to do it at custom.You can do this by following the steps given below.

Install Dependencies using ‘YUM’

# yum install libcurl-devel libmcrypt libmcrypt-devel aspell aspell-devel tidy libtidy libtidy-devel libxslt libxslt-devel 

# cd /var/cpanel/easy/apache/custom_opt_mods/

# wget

# tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-PHP5217.tar.gz

# nano /var/cpanel/easy/apache/rawopts/all_php5



You can enable all relevant PHP modules in “/var/cpanel/easy/apache/rawopts/all_php5”.

Then recompile Apache using “/scripts/easyapache”. Go to step 3 “Please choose which specific PHP version(s) to build”
If you want no PHP except 5.2 then on the “PHP Version” screen chose “None” and continue to step 4, The “Short Options List” page you will see “PHP 5.2.17 support (no FastCGI)” listed. Check that box and continue your EasyApache like normal.

After EasyApache you can re-install IonCubeLoader and Zendopt using :

# /scripts/phpextensionmgr install IonCubeLoader
# /scripts/phpextensionmgr install Zendopt

You can install the following PHP extensions using script ‘/scripts/phpextensionmgr’

  • EAccelerator
  • IonCubeLoader
  • Zendopt
  • Xcache
  • SourceGuardian
  • PHPSuHosin

If necessary you can install other missing PHP modules without doing Easyapache.You can do this simply by login into the server as root :

# cd /home/cpeasyapache/src/php-5.2.17/ext/mcrypt/  (Go to particular extension folder,Here I need to install Mcrypt)

# phpize
# ./configure
# make
# make install

After that you can see extension directory path:

# php -i | grep extension_dir

# ls -al  /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
# vi /usr/local/lib/php.ini

add extension=”” .Then restart apache using :

# /etc/init.d/httpd restart

Other method is:

# wget -O /usr/local/src/tidy-1.2.tgz
# cd /usr/local/src/
# tar zxvf tidy-1.2.tgz
# cd tidy-1.2
# phpize
# ./configure
# make
# make install
# php -i | grep extension_dir
# ls -al  /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
# vi /usr/local/lib/php.ini

add extension=”” extension under your extension directory path and restart apache using:

# /etc/init.d/httpd restart

That’s it !

How to Safely Change the Location of MySQL Data Directory on cPanel/WHM Servers

I had seen many cPanel servers running out of disk space due to MySQL data directory on “/var” partition.To solve this issue you need to move your MySQL data directory to a new location.There are also other situations like moving your MySQL data’s to a new standalone database server or moving it to a separate solid-state-drive partition for increasing MySQL server performance.Whatever the reason, moving MySQL data directory is simple and has no impact on cPanel functionality.

In this article I am moving MySQL data directory to “/home” partition.You can proceed with the following steps for moving MySQL data directory:

1.Create a backup

Please make full database backup(including system tables) before moving your data directory. This action will prevent data losing in case if something goes wrong.

# tar -cvf mysql.tar /var/lib/mysql

2.Edit the my.cnf file

# vi /etc/my.cnf

Now in the mysqld section add the following. Don’t restart MySQL after adding new entry.


3.Create the new MySQL data directory

# mkdir /home/mysql

4.Now migrate the data to the new location using rsync command.

# nohup rsync -avp /var/lib/mysql/ /home/mysql

The nohup will keep rsync running even when your session with the server end, the other part “

# tail -f nohup.out

Notice that you have to do the syncing process twice , because when moving large size of data can take some time to complete and the tables may have changed in between. When we run it the second time we hopefully get it so that when the switch over happens there is very little, if any, lost data. If you can afford the downtime simply shut down MySQL before running this command.If you cannot though running it twice then quickly copy/pasting the other commands is a valid substitute.

5.Typically you want to stop MySQL for syncing data completely.

# /etc/init.d/mysqld stop

6.Start the re-sync process once again to copy data’s completely.

# rsync -avp --delete /var/lib/mysql/ /home/mysql/

7. Change ownership of new created MySQL data directory to MySQL.

# chown -R mysql:mysql /home/mysql/

8. Now, re-link the socket file to /tmp:

# rm -rf /tmp/mysql.sock
# ln -sf /home/mysql/mysql.sock /tmp/mysql.sock

9. Since you already added the data directory entry to my.cnf , all you need to do is restart again and everything should be working.

# /etc/init.d/mysqld start

Check whether your MySQL logs are written at the new location (Eg: /home/mysql/hostname.err)

10. Create a sample database named “foo” for checking.

# mysqladmin create foo

11. Check whether new database is created at new data directory.

# ls -d /home/mysql/foo

12. After confirming every thing works properly.You can remove the old data directory.

# rm -rf  /var/lib/mysql

That’s it !

How to install Percona Server in cPanel/WHM servers

What is Percona Server ?

Percona Server is based on the original MySQL code, but functions as a drop-in that replaces MySQL .Like MySQL, Percona Server is open-source, so it is free and it benefits from additions from the community. Percona Inc. takes these and other improvements and makes them available as a package to the general public.

What are the advantages of using Percona Server ?
  •  Percona Server will be faster and more consistent for your database queries.
  • Percona Server is backward-compatible with MySQL, So your developers don’t need to change code or rewrite queries.
  • Percona Server takes advantage of the advances in multi-core CPUs, multithreading and solid-state drives.
  • Percona Server contains optimized algorithms for background processing, and enhancements to buffers and caches.
  • Percona Server need only less time in tuning and administering.
  • Percona Server can be easily troubleshoot without guesswork.There are more status counters available for monitoring than in MySQL, So you can get a clear picture of what is happening with your database server.
  • Percona Server will save money on hardware upgrades.
How can you replace MySQL with Percona Server in cPanel installed systems ?

Moving from MySQL to Percona Server is relatively straightforward.But this setup is considered to be unsupported by the cPanel/WHM team.So you may need to manage and maintain any updates and maintenance on the database software by your self.

You can do it by following the steps provided here:

Step 1:

Please make full database backup(including system tables) before switching to Percona. This action will prevent data losing in case if something goes wrong.This is the most time consuming section of this process.

# mysqldump --all-databases --routines --triggers > /home/db_dump/alldb.sql
# service mysql stop
# cp -r /var/lib/mysql/mysql /home/db_dump/
# service mysql start
Step 2:

Move your existing mysql configuration file ( /etc/my.cnf ).Your original MySQL my.cnf file should work fine for Percona but to reduce risk factor,I suggest you to move your existing mysql configuration file:

# mv /etc/my.cnf /etc/my.cnf.old
Step 3:

Disable the targets so cPanel no longer handles MySQL updates:

The following will mark the versions of MySQL distribute as uninstalled so they are no longer maintained by cPanel/WHM.

# /scripts/update_local_rpm_versions --edit target_settings.MySQL50 uninstalled
# /scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled
# /scripts/update_local_rpm_versions --edit target_settings.MySQL55 uninstalled
Step 4:

Remove existing MySQL RPMs so there’s a clean slate for Percona.

# /scripts/check_cpanel_rpms --fix --targets=MySQL50,MySQL51,MySQL55
Step 5:

Create a yum repository for Percona:

nano /etc/yum.repos.d/percona.repo

name = CentOS $releasever - Percona
enabled = 1
gpgkey =
gpgcheck = 1
Step 6:

Remove php from the exclude section of /etc/yum.conf file then run the following commands to install Percona Server.

# yum install Percona-Server-client-55 Percona-Server-server-55 Percona-Server-devel-55
# /etc/init.d/mysql start
# mysql_upgrade
# /etc/init.d/mysql restart

Please make sure to add PHP back to exclude section of /etc/yum.conf file.

Step 7:

Compile PHP with newly installed MySQL libraries using :

# /scripts/easyapache --build

Make sure every websites work fine with new Percona Server.


How to reduce memory consumption on a cpanel vps

Run command ‘free -m’ note value under ‘-/+ buffers/cache’ and find out how much memory your vps is currently using ? After that please proceed the following steps:

1) Stopping SpamAssassin:

This program isn’t overly important to the stopping of spam. To turn it off do the following:

Go to WHM » Server Configuration » Tweak Settings » Disable Spamd


Go to WHM » Service Manager » Disable Spamd

2) Stopping Mailman:

If you or none of your customers aren’t running any mail listings through cPanel, it would be a good idea to disable Mailman.

Go to WHM » Server Configuration » Tweak Settings » Disable Mailman

3) Stop ClamAV:

Never use ClamAV on a VPS server.You can use maldet instead of ClamAV.You can disable ClamAV from:

Go to WHM » Home » cPanel » Manage Plugins » Uncheck clamavconnector and save

4) Never Use Tomcat on a VPS:

Never run TomCat on a VPS because of it’s high RAM needs.

5) Disable CatchAll :

If you receive incoming spam mail to a large extend then catchall setup will be reason.Try to catch-all from :

Go to WHM » Server Configuration » Tweak Settings » Change to :fail:

6) Tweak Apache:

Apache need to tweaked compulsory to reduce memory usage, do the following:

WHM » Home » Service Configuration » Apache Configuration » Global Configuration

Change the following settings:

MinSpareServers 2
MaxSpareServers 5
StartServers 3
Keep-Alive Off

Save the values and rebuild apache.

7) Optimize MySQL.

Please replace your existing my.cnf to the following:

max_allowed_packet = 1M
max_connections = 300
max_user_connections = 35
quick max_allowed_packet = 16M

InnoDB requires more RAM and it in not good for a VPS server. Better prefer MyISAM tables.So i suggest you to convert InnoDB tables to MyISAM.

9) Optimize PHP

Reduce PHP memory limit from php.ini.

10) Backup Type :

Never use compressed backup type.Instead of compress backup use incremental backup.You can configure it from WHM » Home » Backup » Backup Configuration

11) Disable Unwanted Services.
hcid or sdpd
hpiod or

All that should reduce your memory usage by a large amount.

Please reboot your VPS for one time.After server is up run ‘free -m’ command and feel the difference in memory usage.

How to Configure Multiple shared IPs in WHM

Ever wondered how to set up multiple shared IPs in WHM? Here is how.

You can’t add multiple shared IPs in WHM GUI, but it’s possible to do so via SSH (login as root).

First, you need to create a /var/cpanel/mainips/ directory, if it doesn’t exist:

# mkdir /var/cpanel/mainips/

Then, create a /var/cpanel/mainips/root file, with all the Ips as folllows

Basically, each line is an additional shared IP in WHM. That’s it!

You can verify from WHM>>Home>>IP Functions>>Show/Edit Reserved IPs

Install Mhash in php 5.3+ in cPanel Centos Linux servers

The php-mhash installation in php 5.3 is very easy. Please use the following steps to install it

1) Download the latest mhash from and install it as follows,

# tar -xzf  mhash-
# ./configure --prefix=/opt/mhash
#  make
#  make install

2) Now add it to the loader configuration in /etc/


3) Now edit the file /var/cpanel/easy/apache/rawopts/all_php5 and add the following line


4) Finally compile the php using the following command

#  /scripts/easyapache --build

You can test the mhash by creating a phpinfo page in your website document root.