{"id":432,"date":"2018-10-17T10:53:57","date_gmt":"2018-10-17T10:53:57","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/optimize-mysql-apache-on-cpanel-whm-server-elinux-co-in-linux-cpanel-whm-blog\/"},"modified":"2018-10-17T10:53:57","modified_gmt":"2018-10-17T10:53:57","slug":"optimize-mysql-apache-on-cpanel-whm-server-elinux-co-in-linux-cpanel-whm-blog","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/optimize-mysql-apache-on-cpanel-whm-server-elinux-co-in-linux-cpanel-whm-blog\/","title":{"rendered":"Optimize MySQL &amp; Apache on cPanel\/WHM server | Elinux.co.in | Linux Cpanel\/ WHM blog"},"content":{"rendered":"\n<p>On this optimization process, we will go over the <a href=\"https:\/\/www.elinux.co.in\/category\/apache\/\">Apache<\/a> core configuration and modules that are part of <a href=\"https:\/\/www.elinux.co.in\/tag\/apache\/\">Apache<\/a> core. We think that with the correct settings of Apache and MySQL you can get excellent results and the correct level of resource use without installing third-party proxy and cache modules. So let\u2019s start,<\/p>\n<h3>Apache &amp; PHP<\/h3>\n<p>In the first stage we run the Easy Apache and selected the following:<\/p>\n<ul>\n<li>Apache Version 2.4+<\/li>\n<li>\n<p>PHP Version 5.6+<\/p>\n<\/li>\n<li>\n<p>In step 5 \u201cExhaustive Options List\u201d select<\/p>\n<\/li>\n<\/ul>\n<p>\u2013 Deflate<\/p>\n<p>\u2013 Expires<\/p>\n<p>\u2013 MPM Worker<\/p>\n<p>After Easy Apache finished go to your WHM \u00bb Service Configuration \u00bb Apache Configuration \u00bb \u201cGlobal Configuration\u201d and set the values by the level of resources available on your server.<\/p>\n<blockquote><p>Apache Directive (From 2GB memory or less and to 12GB+ memory) <\/p>\n<p>StartServers 4 8 16<br \/>\nMinSpareServers 4 8 16<br \/>\nMaxSpareServers 8 16 32<br \/>\nServerLimit 128 256 512<br \/>\nMaxRequestWorkers 150 250 500<br \/>\nMaxConnectionsPerChild 1000 2500 5000<br \/>\nKeep-Alive On On On<br \/>\nKeep-Alive Timeout 1 1 1<br \/>\nMax Keep-Alive Requests 30 30 30<br \/>\nTimeout 60 60 60<\/p>\n<\/blockquote>\n<p>Now go to WHM \u00bb Service Configuration \u00bb Apache Configuration \u00bb Include Editor \u00bb \u201cPre VirtualHost Include\u201d and allow users minimal cache and data compression to allow the server to work less for the same things by pasting the code below into the text field.<\/p>\n<blockquote><p># Cache Control Settings for one hour cache<br \/>\n&lt;FilesMatch &#8220;.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$&#8221;&gt;<br \/>\nHeader set Cache-Control &#8220;max-age=3600, public&#8221;<br \/>\n&lt;\/FilesMatch&gt;<\/p>\n<p>&lt;FilesMatch &#8220;.(xml|txt)$&#8221;&gt;<br \/>\nHeader set Cache-Control &#8220;max-age=3600, public, must-revalidate&#8221;<br \/>\n&lt;\/FilesMatch&gt;<\/p>\n<p>&lt;FilesMatch &#8220;.(html|htm)$&#8221;&gt;<br \/>\nHeader set Cache-Control &#8220;max-age=3600, must-revalidate&#8221;<br \/>\n&lt;\/FilesMatch&gt;<\/p>\n<p># Mod Deflate performs data compression<br \/>\n&lt;IfModule mod_deflate.c&gt;<br \/>\n&lt;FilesMatch &#8220;.(js|css|html|php|xml|jpg|png|gif)$&#8221;&gt;<br \/>\nSetOutputFilter DEFLATE<br \/>\nBrowserMatch ^Mozilla\/4 gzip-only-text\/html<br \/>\nBrowserMatch ^Mozilla\/4.0[678] no-gzip<br \/>\nBrowserMatch bMSIE no-gzip<br \/>\n&lt;\/FilesMatch&gt;<br \/>\n&lt;\/IfModule&gt;<\/p>\n<\/blockquote>\n<p>Go to WHM \u00bb Service Configuration \u00bb \u201cPHP Configuration Editor\u201d and set the parameters according to your needs:<\/p>\n<p>\u2013 memory_limit<\/p>\n<p>\u2013 max_execution_time<\/p>\n<p>\u2013 max_input_time<\/p>\n<h3>MySQL<\/h3>\n<p>For MySQL you need to update the configuration file that usually in \/etc\/my.cnf<\/p>\n<p>Best config base on 2 core &amp; 4GB memory MySQL 5.6  MariaDB 10:<\/p>\n<blockquote><p>[mysqld]<br \/>\n local-infile = 0<br \/>\n max_connections = 250<br \/>\n key_buffer = 64M<br \/>\n myisam_sort_buffer_size = 64M<br \/>\n join_buffer_size = 1M<br \/>\n read_buffer_size = 1M<br \/>\n sort_buffer_size = 2M<br \/>\n max_heap_table_size = 16M<br \/>\n table_cache = 5000<br \/>\n thread_cache_size = 286<br \/>\n interactive_timeout = 25<br \/>\n wait_timeout = 7000<br \/>\n connect_timeout = 15<br \/>\n max_allowed_packet = 16M<br \/>\n max_connect_errors = 10<br \/>\n query_cache_limit = 2M<br \/>\n query_cache_size = 32M<br \/>\n query_cache_type = 1<br \/>\n tmp_table_size = 16M<br \/>\n open_files_limit=25280<\/p>\n<p>[mysqld_safe]<\/p>\n<p>[mysqldump]<br \/>\n quick<br \/>\n max_allowed_packet = 16M<br \/>\n[myisamchk]<br \/>\n key_buffer = 64M<br \/>\n sort_buffer = 64M<br \/>\n read_buffer = 16M<br \/>\n write_buffer = 16M<br \/>\n[mysqlhotcopy]<br \/>\n interactive-timeout<\/p><\/blockquote>\n<p>Best config base on 8 core &amp; 16GB+ memory (Shared server) MySQL 5.6  MariaDB 10:<\/p>\n<blockquote>\n<p>[mysqld]<br \/>local-infile=0<br \/>max_connections = 600<br \/>max_user_connections=1000<br \/>key_buffer_size = 512M<br \/>myisam_sort_buffer_size = 64M<br \/>read_buffer_size = 1M<br \/>table_open_cache = 5000<br \/>thread_cache_size = 384<br \/>wait_timeout = 20<br \/>connect_timeout = 10<br \/>tmp_table_size = 256M<br \/>max_heap_table_size = 128M<br \/>max_allowed_packet = 64M<br \/>net_buffer_length = 16384<br \/>max_connect_errors = 10<br \/>concurrent_insert = 2<br \/>read_rnd_buffer_size = 786432<br \/>bulk_insert_buffer_size = 8M<br \/>query_cache_limit = 5M<br \/>query_cache_size = 128M<br \/>query_cache_type = 1<br \/>query_prealloc_size = 262144<br \/>query_alloc_block_size = 65535<br \/>transaction_alloc_block_size = 8192<br \/>transaction_prealloc_size = 4096<br \/>max_write_lock_count = 8<br \/>slow_query_log<br \/>log-error<br \/>external-locking=FALSE<br \/>open_files_limit=50000<\/p>\n<p>[mysqld_safe]<\/p>\n<p>[mysqldump]<br \/>quick<br \/>max_allowed_packet = 16M<\/p>\n<p>[isamchk]<br \/>key_buffer = 384M<br \/>sort_buffer = 384M<br \/>read_buffer = 256M<br \/>write_buffer = 256M<\/p>\n<p>[myisamchk]<br \/>key_buffer = 384M<br \/>sort_buffer = 384M<br \/>read_buffer = 256M<br \/>write_buffer = 256M<\/p>\n<p>sort_buffer_size = 1M<br \/>join_buffer_size = 1M<br \/>thread_stack = 192K<\/p>\n<\/blockquote>\n<p> <a href=\"https:\/\/www.elinux.co.in\/optimize-mysql-apache-cpanel-whm-server\/#utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=optimize-mysql-apache-cpanel-whm-server\" target=\"_blank\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>On this optimization process, we will go over the Apache core configuration and modules that are part of Apache core. We think that with the correct settings of Apache and MySQL you can get excellent results and the correct level of resource use without installing third-party proxy and cache modules. So let\u2019s start, Apache &amp; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/17\/optimize-mysql-apache-on-cpanel-whm-server-elinux-co-in-linux-cpanel-whm-blog\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Optimize MySQL &amp; Apache on cPanel\/WHM server | Elinux.co.in | Linux Cpanel\/ WHM blog&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-432","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":0,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}