{"id":30053,"date":"2019-10-31T21:33:26","date_gmt":"2019-10-31T18:33:26","guid":{"rendered":"https:\/\/prohoster.info\/blog\/optimizatsiya-proizvoditelnosti-apache2\/"},"modified":"2019-10-31T21:33:26","modified_gmt":"2019-10-31T18:33:26","slug":"optimizatsiya-proizvoditelnosti-apache2","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/optimizatsiya-proizvoditelnosti-apache2","title":{"rendered":"Apache2 performance optimization","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Many use apache2 as a web server. However, few think about optimizing its performance, which directly affects the website's page loading speed, script processing speed (especially PHP), as well as CPU load and increased RAM usage. <\/p>\n<p>Thus, the following manual should help beginners (and not only) users.<br \/>\nAll the examples provided below were used on Raspberry PI 3, Debian 9, Apache 2.4.38, PHP 7.3.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\nSo, let's get started.<\/p>\n<h3>1. Disabling unused modules<\/h3>\n<p>\nThe first method is simply disabling modules that you do not use:<\/p>\n<p>You can view the list of currently used modules with the command:<\/p>\n<pre><code class=\"bash\">apache2ctl -M<\/code><\/pre>\n<p>\nTo disable a module, use the command:<\/p>\n<pre><code class=\"bash\">a2dismod *module name*<\/code><\/pre>\n<p>\nAccordingly, to enable a module, use the command:<\/p>\n<pre><code class=\"bash\">a2enmod *module name*<\/code><\/pre>\n<p>\nNote that when using <i>a2dismod<\/i>, the module name should be written without the word module itself.<\/p>\n<p>For example, if you see <i>apache2ctl -M<\/i> in the output of the command <i>proxy_module<\/i>, then to disable it, you need to use the command \u2014 <i>a2dismod proxy<\/i><\/p>\n<p>The most system resource-consuming modules (based on personal experience) are:<\/p>\n<ul>\n<li>PHP, Ruby, Perl, and other modules for various scripting languages<\/li>\n<li><a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/en\/ssl-sertifikat\/\"   title=\"SSL\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"2258\">SSL<\/a><\/li>\n<li>Rewrite<\/li>\n<li>CGI<\/li>\n<\/ul>\n<p>\nSo, in cases where you do not need these modules, I recommend disabling them.<\/p>\n<p>Also, after disabling any module, I recommend using the command \u2014 <i>apache2ctl configtest<\/i>, which will check the configuration of the websites being used and, if any of the disabled modules were necessary for them, will issue an error.<\/p>\n<h3>2. Changing MPM (Multi-Processing Module) and using php-fpm<\/h3>\n<p>\nBy default, after installation, apache2 uses MPM Prefork (1 thread per 1 connection), which significantly reduces performance but improves stability and security.<\/p>\n<p>However, for performance optimization, I recommend using MPM Worker, which allows multiple threads for a single connection.<\/p>\n<p>To enable it, use the following commands:<\/p>\n<pre><code class=\"bash\">a2dismod mpm_prefork  \/\/Disable prefork\na2dismod php7.3  \/\/Disable the php module that depends on prefork\na2enmod mpm_worker  \/\/Enable worker\n<\/code><\/pre>\n<p>\nHowever, when using Worker, you may encounter a problem since the php7.3 module depends on the Prefork module.<\/p>\n<p>To solve this problem, we will install the php7.3-fpm module, which will be used for executing php scripts:<\/p>\n<pre><code class=\"bash\">apt-get update &amp;&amp; apt-get install php7.3-fpm  \/\/ Installing\nsystemctl enable php7.3-fpm &amp;&amp; systemctl start php7.3-fpm  \/\/ Enabling and starting the service\na2enmod php7.3-fpm &amp;&amp; a2enconf php7.3-fpm.conf  \/\/ Enabling the module and its configuration\n<\/code><\/pre>\n<p>\nIt is worth noting that using php-fpm will also reduce the amount of RAM used by the apache2 process and slightly speed up the execution of php scripts.<\/p>\n<h3>3. Conclusion<\/h3>\n<p>\nThus, with these simple actions, we managed to optimize performance and reduce the load on the machine (in this case, RPI3).<\/p>\n<p>Of course, there are hundreds of other optimization options, such as enabling compression (which is indeed useful but mostly already enabled by default), changing the parameters (configuration files) of MPM, disabling HostnameLookups, etc., but in this article, I aimed to highlight the points that helped me the most, and I hope they will help others.<br \/>\n<br \/>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/444732\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 apache2 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0431 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u043f\u0440\u044f\u043c\u043e \u043f\u0440\u043e\u043f\u043e\u0440\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441\u0430\u0439\u0442\u0430, \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 (\u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 php), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u0440\u043e\u0441\u0442\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0426\u041f \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0451\u043c\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u041e\u0417\u0423. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0430\u043d\u0443\u0430\u043b, \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e) \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c. \u0412\u0441\u0435 \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-30053","post","type-post","status-publish","format-standard","hentry","category-blog"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.1.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 apache2 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/optimizatsiya-proizvoditelnosti-apache2\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.1.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 apache2 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 apache2 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/optimizatsiya-proizvoditelnosti-apache2\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T18:33:26+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T18:33:26+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Apache2 Performance Optimization | ProHoster","description":"Many use apache2 as a web server.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/optimizatsiya-proizvoditelnosti-apache2","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 apache2 | ProHoster","og:description":"\u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 apache2 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0435\u0440\u0430.","og:url":"https:\/\/prohoster.info\/en\/blog\/optimizatsiya-proizvoditelnosti-apache2","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T18:33:26+00:00","article:modified_time":"2019-10-31T18:33:26+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"30053","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-02-09 17:29:02","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 03:43:14","updated":"2026-02-09 17:29:02","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/30053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=30053"}],"version-history":[{"count":1,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/30053\/revisions"}],"predecessor-version":[{"id":159502,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/30053\/revisions\/159502"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=30053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=30053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=30053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}