CodeClouds Color Logo CodeClouds White Logo

If you want your business to succeed online, it’s very important to maintain a reliable and secure service. We have dealt with the fundamentals of WHM/cPanel Hardening & Security in our previous edition. Get to know more with our second edition, focused on cPanel/WHM – Optimizing your CentOS Virtual Servers.

When wanting to succeed with your online business, it’s very important that you maintain a reliable and secure service. Today we will be looking at the on Part two of cPanel/WHM – Optimizing your CentOS Virtual Servers.

In today’s blog, we will be looking deeper into Database Tuning, MySQL to MariaDB Migration, Installing APC / APCu as well as how to tune NGINX using Engintron on top of your WHM server.

optimizing centos virtual servers

Improving Database Performance
When perfecting a dynamic environment, you can expect large performance improvements after optimizing your databases. To optimize your database, you can look into several methods.

SQL Tuning
The methods below are the most common for SQL tuning with cPanel. For more information, you can visit Tweak Settings – SQL.

Include databases in disk usage calculations
If you enable this setting, your server will include databases in disk usage calculations. This settings value defaults to On.

Use INFORMATION_SCHEMA to acquire MySQL disk usage
If you enable this setting, your server will use MySQL’s INFORMATION_SCHEMA view to include disk usage by all MySQL tables in the disk usage totals.

If you disable this setting, cPanel & WHM queries the filesystem for MySQL’s disk usage information. Table type usage and local configuration may cause inaccuracy in the disk usage totals.

This settings value defaults to On.

Note: If you use a remote MySQL server, you must select On in order to calculate MySQL disk usage.
Warning: This setting causes MySQL to become unresponsive until data collection finishes, which may degrade your system’s performance.

Use pre-4.1-style MySQL passwords
This setting allows you to select whether you wish to use old pre-MySQL 4.1 passwords with your current version of MySQL. This can be useful if you experience authentication problems with PHP scripts.

This settings value defaults to Off.


  • You must restart MySQL to apply this setting. Use WHM’s SQL Server (MySQL) interface (Home >> Restart Services >> SQL Server (MySQL)) to restart MySQL.
  • This setting only applies to MySQL 5.5 and earlier. MySQL 5.6 removed support for old-style passwords.
  • Your server will not automatically reset old-style passwords when you change this setting to Off. Any users with old-style passwords cannot authenticate until you or they reset their passwords. To reset old-style passwords, use cPanel’s Password & Security interface (Home >> Preferences >> Password & Security) or WHM’s Password Modification interface (Home >> Account Functions >> Password Modification).
  • To determine whether any users have old-style passwords, run the following query in the MySQL command prompt:
    mysql> SELECT user, Length(Password) FROM mysql.user;
  • Users who return a 16-character length use the pre-4.1-style MySQL password.

Allow cPanel & WHM to determine the best value for your MySQL open_files_limit configuration
This setting allows cPanel & WHM to determine the best value for your MySQL open_files_limit setting in your my.cnf configuration file. The system uses the total number of open tables in your databases to determine this value.

Newer versions of MySQL require additional file descriptors for each open table. A server with a large number of open tables (for example, servers with multiple installations of WordPress®) may require an open_files_limit value that is greater than the default value of 2048. However, an extremely large open_files_limit setting requires more memory, and may cause performance issues.

This settings value defaults to On.

Allow cPanel & WHM to determine the best value for your MySQL max_allowed_packet configuration
This setting allows cPanel to determine the best value for your MySQL max_allowed_packet setting in your my.cnf configuration file.

The max_allowed_packet setting determines the maximum size of a single packet for any generated or intermediate string. If you use very long BLOB columns or long strings, this setting must be large enough to handle them properly. However, an extremely large max_allowed_packet setting may catch unnecessarily large packets, and may cause performance issues.

This settings value defaults to On.

Allow cPanel & WHM to determine the best value for your MySQL innodb_buffer_pool_size configuration
This setting allows cPanel & WHM to determine the best value for your MySQL innodb_buffer_pool_size setting in your my.cnf configuration file.

The innodb_buffer_pool_size setting determines the size of the memory buffer, in bytes, that the InnoDB storage engine uses to cache data and indexes of its tables. However, an extremely large innodb_buffer_pool_size setting requires more memory, and may cause performance issues.

If you select On for this setting, the system uses the following defaults:

  • For servers with less than 512 Megabytes (MB) of RAM, the system sets the innodb_buffer_pool_size setting to 8 MB.
  • For servers with between 512 MB and 4 Gigabytes (GB) of RAM, the system sets the innodb_buffer_pool_size setting to a proportional value that is between 8 and 128 MB.
  • For servers with more than 4 GB of RAM, the system sets the innodb_buffer_pool_size setting to 128 MB.

This settings value defaults to On.

Require a username prefix on names of new databases and database users
When you enable database prefixing, the system prefixes database names and database usernames with the first eight characters of the system username and an underscore (_). This makes it easier for you to determine which user owns a given database, but it reduces the number of characters that users can use for names of databases and database users.

Note: If you change the system account name, database names and database usernames that the account owns do not change.

This settings value defaults to On.

MySQL to MariaDB Migration
Altering your database is not the only option you can look at to speed up your download times. Another handy tip you can look into is to migrate your MySQL databases to MariaDB. MariaDB was developed in 2009 and has grown to be one of the most responsive and well used database system used today. MariaDB has a much improved query optimizer, faster joins, and many other performance related improvements. Certain benchmarks show that MariaDB is radically faster than MySQL.

As MariaDB works to be as similar as possible to MySQL, its version numbers used to correlate directly with MySQL’s. To this effect, MariaDB 5.5 had all of the features of MySQL 5.5, as well some of the original ones that improved upon MySQL’s functionality.

However, as MariaDB continues to build out its own features and divest from MySQL, MariaDB version names are taking on a new convention. With the differing schedules of MySQL and MariaDB feature releases, MariaDB’s latest version is 10.0.

When using WHM, you can migrate to MariaDB by following the steps below.

Step 1: Backup existing MySQL data
Make sure to save all existing data just in case there are any issues.

cp -Rf /var/lib/mysql /var/lib/mysql-old
mv /etc/my.cnf /etc/my.cnf-old

Step 2: Disable the targets so cPanel no longer handles MySQL updates
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 there’s 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


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

Final Step: Rebuild easyapache/php to ensure modules are intact/working
/scripts/easyapache --build

Installing APC
When running PHP, it can be very beneficial to run some sort of caching system to reduce direct requests made to your server. APC or Alternative PHP Cache is a free open-source opcode (operation code) caching plugin for PHP. With APC caching your PHP script executions can run more efficiently, by cutting down on dynamic PHP executions.


After you install APC, you will want to learn how to view and clear the APC cache. That way you can keep tabs on what APC is caching, and how effective it might be working for your website.

To install APC you’ll need to have root access on either a VPS or dedicated server. You also will need to be running either the FastCGI or DSO PHP handlers for APC to function properly.

1. Login to your server via SSH with your root SSH access.

2. Change directories with the following command: cd /usr/local/src

3. Get the source code for APC with the following code: wget

4. Now extract the APC archive with this command: tar xvzf APC-3.1.13.tgz

5. Navigate into the extracted folder: cd APC-3.1.13

6. Now run the following command to configure APC to your PHP environment: phpize
You should get something like this back:
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626

7. Next configure the source code to run on your server with this command:

You’ll see a lot of text scrolling by looking like this:
checking for egrep… /bin/grep -E
checking for a sed that does not truncate output… /bin/sed
checking for cc… cc
creating libtool
appending configuration tag “CXX” to libtool
configure: creating ./config.status
config.status: creating config.h

8. Now you’ll want to actually create the APC software with this command:

Again you’ll see a lot of text scrolling by looking like:
/bin/sh /usr/local/src/APC-3.1.13/libtool --mode=compile cc -I.
-I/usr/local/src/APC-3.1.13 -DPHP_ATOM_INC -I/usr/local/src/APC-3.1.13/include
-I/usr/local/src/APC-3.1.13/main -I/usr/local/src/APC-3.1.13
-I/usr/local/include/php -I/usr/local/include/php/main
-I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend
-I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c
/usr/local/src/APC-3.1.13/apc.c -o apc.lo mkdir .libs

Libraries have been installed in:
Build complete.

9. Locate the extension_dir for PHP with this command:
grep extension_dir /usr/local/lib/php.ini

You should get back a path that looks something like:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"

10. Run this command to copy the APC Apache module ( to your PHP extension directory:
cp -frp modules/ /usr/local/lib/php/extensions/no-debug-non-zts-20090626/

11. Edit your php.ini file with your favorite text editor after making a backup:
cp -frp /usr/local/lib/php.ini /usr/local/lib/php.ini-BAK
vi /usr/local/lib/php.ini

Add these APC settings to the very bottom and save the php.ini file:
apc.optimization = 0
apc.use_request_time = 1

12. Place the following code inside a info.php script on your site:
<?php phpinfo(); ?>

13. Access that script on your site such as Look for the apc section:


Installation/Tweaking Engintron
Another tool you can use to help optimize your site additionally is Engintron. Engintron for cPanel/WHM is the easiest way to integrate Nginx on your cPanel/WHM server.

Engintron will improve the performance & web serving capacity of your server, while reducing CPU/RAM load at the same time. It does that by installing & configuring the popular Nginx web server to act as a reverse caching proxy for static files (like CSS, JS, images etc.) with an additional micro-cache layer to significantly improve performance of dynamic content generated by CMSs like WordPress, Joomla or Drupal as well as forum software like vBulletin, phpBB, SMF or e-commerce solutions like Magento, OpenCart, PrestaShop and others.

Version 1.7.x does not currently support TLS/SSL, however, they have announced to add this support with their 1.8.0 release.

Installing Engintron
To install and tweak Engintron, follow the steps below. Additionally, you can visit their GitHub ReadMe here.

Installation is a process that lasts only a few minutes. You’ll need root SSH access to your cPanel server. Log in as root and type the following commands, one at a time:

cd /
rm -f
wget --no-check-certificate
bash install

Or in one quick command to paste in the terminal:

cd /; rm -f; wget --no-check-certificate;
bash install

The process will take a couple of minutes to complete and after that, Engintron will be installed on your cPanel server. Engintron has a nice user interface which is activated inside WHM, under the Plugins section. After installation, refresh WHM in your browser and you should see Engintron in the Plugins section (it’s the absolute last section in WHM’s sidebar).

Tweaking Engintron
In there, you’ll find basic options to control Nginx, Apache, and MySQL, all in one convenient place. Additionally, you can edit all of Nginx’s configuration files (as well as some from Apache & MySQL) to get even more from Engintron (e.g. configure Engintron for use with CloudFlare). If however, all you want is to accelerate both static & dynamic content delivery, then Engintron is already setup for you and you don’t need to do anything more.

Inside the Engintron app dashboard, you’ll also find some handy utilities to monitor things like your Nginx access & error logs, check processes on your server or see incoming traffic on port 80.