{"id":3166,"date":"2014-10-07T15:07:11","date_gmt":"2014-10-07T15:07:11","guid":{"rendered":"http:\/\/www.deuzebranaweb.com.br\/?p=3166"},"modified":"2014-10-07T15:07:11","modified_gmt":"2014-10-07T15:07:11","slug":"optimize-mysql-apache-on-cpanelwhm-server-gkblog","status":"publish","type":"post","link":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/2014\/10\/07\/optimize-mysql-apache-on-cpanelwhm-server-gkblog\/","title":{"rendered":"Optimize MySQL &#038; Apache on cPanel\/WHM server \u2013 GK~Blog"},"content":{"rendered":"<div class=\"entry-body\">\n<h2 class=\"entry-title\">Optimize MySQL &amp; Apache on cPanel\/WHM server<\/h2>\n<\/div>\n<div class=\"entry-content\">\n<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\u00a0proxy and\u00a0cache modules. So let\u2019s start,<\/p>\n<p>&nbsp;<\/p>\n<h3>Apache &amp; PHP<\/h3>\n<p>In the first stage we run the Easy Apache and selected the following:<\/p>\n<p>* Apache Version 2.4+<\/p>\n<p>* PHP Version 5.4+<\/p>\n<p>* In step 5 \u201cExhaustive Options List\u201d select<\/p>\n<p>\u2013 Deflate<\/p>\n<p>\u2013 Expires<\/p>\n<p>\u2013 MPM Prefork<\/p>\n<p>\u2013 MPM Worker<\/p>\n<p>After\u00a0Easy 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<pre>Apache Directive \t \t(From 2GB memory or less and up to 12GB memory) \t \t\n\nStartServers \t \t \t4 \t \t8 \t \t16 \t\nMinSpareServers \t \t4 \t \t8 \t \t16 \t\nMaxSpareServers \t \t8 \t \t16 \t \t32 \t\nServerLimit \t \t \t64 \t \t128 \t \t256 \t\nMaxRequestWorkers \t \t50 \t \t120 \t \t250 \t\nMaxConnectionsPerChild \t \t1000 \t \t2500 \t \t5000 \nKeep-Alive\t\t\tOn\t\tOn\t\tOn\nKeep-Alive Timeout\t \t5\t \t5\t \t 5\nMax Keep-Alive Requests\t\t50\t \t120\t \t120\nTimeout\t\t\t\t30\t\t60\t\t60<\/pre>\n<p>&nbsp;<\/p>\n<p>Now go to WHM \u00bb Service Configuration \u00bb Apache Configuration \u00bb Include Editor \u00bb \u201cPre VirtualHost Include\u201d and allow users minimal\u00a0cache and\u00a0data compression to allow the server to work less for the same things by pasting the code below into the text field.<\/p>\n<pre># Cache Control Settings for one hour cache\n&lt;FilesMatch \".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$\"&gt;\nHeader set Cache-Control \"max-age=3600, public\"\n&lt;\/FilesMatch&gt;\n\n&lt;FilesMatch \".(xml|txt)$\"&gt;\nHeader set Cache-Control \"max-age=3600, public, must-revalidate\"\n&lt;\/FilesMatch&gt;\n\n&lt;FilesMatch \".(html|htm)$\"&gt;\nHeader set Cache-Control \"max-age=3600, must-revalidate\"\n&lt;\/FilesMatch&gt;\n\n# Mod Deflate performs data compression\n&lt;IfModule mod_deflate.c&gt;\n&lt;FilesMatch \".(js|css|html|php|xml|jpg|png|gif)$\"&gt;\nSetOutputFilter DEFLATE\nBrowserMatch ^Mozilla\/4 gzip-only-text\/html\nBrowserMatch ^Mozilla\/4.0[678] no-gzip\nBrowserMatch bMSIE no-gzip\n&lt;\/FilesMatch&gt;\n&lt;\/IfModule&gt;<\/pre>\n<p>&nbsp;<\/p>\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<p>&nbsp;<\/p>\n<h3>MySQL<\/h3>\n<p>For MySQL you need to update the configuration file that\u00a0usually in \/etc\/my.cnf<\/p>\n<p>Best config base on 1 core &amp; 2GB memory MySQL 5.5:<\/p>\n<pre>[mysqld]\n    local-infile = 0\n    max_connections = 250\n    key_buffer = 64M\n    myisam_sort_buffer_size = 64M\n    join_buffer_size = 1M\n    read_buffer_size = 1M\n    sort_buffer_size = 2M\n    max_heap_table_size = 16M\n    table_cache = 5000\n    thread_cache_size = 286\n    interactive_timeout = 25\n    wait_timeout = 7000\n    connect_timeout = 15\n    max_allowed_packet = 16M\n    max_connect_errors = 10\n    query_cache_limit = 2M\n    query_cache_size = 32M\n    query_cache_type = 1\n    tmp_table_size = 16M\n    open_files_limit=2528\n\n[mysqld_safe]\n\n[mysqldump]\n    quick\n    max_allowed_packet = 16M\n[myisamchk]\n    key_buffer = 64M\n    sort_buffer = 64M\n    read_buffer = 16M\n    write_buffer = 16M\n[mysqlhotcopy]\n    interactive-timeout<\/pre>\n<p>&nbsp;<\/p>\n<p>Best config base on 8 core &amp; 12GB memory (Shared server) MySQL 5.5:<\/p>\n<pre>[mysqld]\nlocal-infile=0\nmax_connections = 600\nmax_user_connections=1000\nkey_buffer_size = 512M\nmyisam_sort_buffer_size = 64M\nread_buffer_size = 1M\ntable_open_cache = 5000\nthread_cache_size = 384\nwait_timeout = 20\nconnect_timeout = 10\ntmp_table_size = 256M\nmax_heap_table_size = 128M\nmax_allowed_packet = 64M\nnet_buffer_length = 16384\nmax_connect_errors = 10\nconcurrent_insert = 2\nread_rnd_buffer_size = 786432\nbulk_insert_buffer_size = 8M\nquery_cache_limit = 5M\nquery_cache_size = 128M\nquery_cache_type = 1\nquery_prealloc_size = 262144\nquery_alloc_block_size = 65535\ntransaction_alloc_block_size = 8192\ntransaction_prealloc_size = 4096\nmax_write_lock_count = 8\nslow_query_log\nlog-error\nexternal-locking=FALSE\nopen_files_limit=50000\n\n[mysqld_safe]\n\n[mysqldump]\nquick\nmax_allowed_packet = 16M\n\n[isamchk]\nkey_buffer = 384M\nsort_buffer = 384M\nread_buffer = 256M\nwrite_buffer = 256M\n\n[myisamchk]\nkey_buffer = 384M\nsort_buffer = 384M\nread_buffer = 256M\nwrite_buffer = 256M\n\n#### Per connection configuration ####\nsort_buffer_size = 1M\njoin_buffer_size = 1M\nthread_stack = 192K<\/pre>\n<p>&nbsp;<\/p>\n<p>Repair &amp; optimize databases then restart MySQL:<\/p>\n<pre>mysqlcheck --check --auto-repair --all-databases\nmysqlcheck --optimize --all-databases\n\/etc\/init.d\/mysql restart<\/pre>\n<p>&nbsp;<\/p>\n<h3>http:\/\/www.gk-root.com\/GK-Blog\/optimize-mysql-apache-on-cpanelwhm-server\/<\/h3>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Optimize MySQL &amp; Apache on cPanel\/WHM server 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&#8230;<\/p>\n","protected":false},"author":2,"featured_media":3167,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_angie_page":false,"page_builder":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-3166","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sem-categoria"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/comments?post=3166"}],"version-history":[{"count":0,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/posts\/3166\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/media\/3167"}],"wp:attachment":[{"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/media?parent=3166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/categories?post=3166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.deuzebranaweb.com.br\/index.php\/wp-json\/wp\/v2\/tags?post=3166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}