Press "Enter" to skip to content

Optimize MySQL/MariaDB & Apache under EasyApache 4


First run the Easy Apache 4, Remove unused modules and selected the following:
Apache 2.4+
PHP 7.0 (Optional)

* The MPM Worker uses several threads per child processes, where each thread handles one connection at a time. This is a good choice for high-traffic servers as it allows more concurrent connections to be handled with less RAM than in the previous case.

* Deflate is Gzip your content before sending it off and then the client will ungzip upon receipt, this will minimize the size of file transfers, it generally will help all user experience

* PHP 7 The most easily recognizable advantage of the new PHPNG engine is the significant performance improvement. The development team of PHPNG refactored the Zend Engine, and remarkably optimized memory usage. By using PHP 7 your code will be executed 40% faster.

WHM » Service Configuration » Apache Configuration » “Global Configuration” and set the values by the level of resources available on your server.

Apache Directive (From 2GB memory or less and to 12GB+ memory) 	 	
StartServers 	 	 	4 	 	8 	 	16 	
MinSpareServers 	 	4 	 	8 	 	16 	
MaxSpareServers 	 	8 	 	16 	 	32 	
ServerLimit 	 	 	128 	 	256 	 	512 	
MaxRequestWorkers 	 	150 	 	250 	 	500 	
MaxConnectionsPerChild 	 	1000 	 	2500 	 	5000 
Keep-Alive			On		On		On
Keep-Alive Timeout	 	1	 	1	 	 1
Max Keep-Alive Requests		30	 	30	 	30
Timeout				60		60		60

WHM » Service Configuration » Apache Configuration » Include Editor » “Pre VirtualHost Include”

HostnameLookups off
ExtendedStatus Off
<IfModule mod_deflate.c>
<FilesMatch ".(js|css|html|xml|jpg|png|gif)$">
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE no-gzip

Save and restart Apache.

MySQL / MariaDB

My recommendation is to upgrade MySQL to MariaDB, That contains significant improvements in performance for InnoDB engine.
To upgrade MySQL to MariaDB go to Home » Software » MySQL/MariaDB Upgrade And select MariaDB 10.1.

MySQL/MariaDB optimized to perform in accordance with the specific use on the specific server.
The goal in optimization is to allow MySQL to work properly but without taking all the server resources.

To start optimize edit your /etc/my.cnf And leave only those lines:

local-infile = 0
query_cache_limit = 2M
query_cache_size = 32M
query_cache_type = 1
max_allowed_packet = 32M

This will enable query_cache And set all settings to defaults.
Then fix fragmented tables and restart MySQL/MariaDB by:

 mysqlcheck --auto-repair --optimize --all-databases

Now download and run mysqltuner script and follow the recommendations:

wget -O

To understand in detail the important results, read this article:

And to finish with the optimization of MySQL/MariaDB, Wait 48 hours and run the mysqltuner script again and follow the recommendations.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *