Need Assistance?

In only two hours, with an average response time of 15 minutes, our expert will have your problem sorted out.

Server Trouble?

For a single, all-inclusive fee, we guarantee the continuous reliability, safety, and blazing speed of your servers.

Apache Server Optimization

Apache HTTP Server is free software that is fast and secure and runs over half of all web servers around the globe. By customizing the Apache configuration, you can improve Apache performance without adding additional hardware such as RAM, CPU, etc.

Keep Apache Updated

Even though security bugs are seldom found within the web server, an apache update is important in order to take advantage of the latest security features available.  

Optimize Apache settings

In order to optimize web server performance, several apache settings can be tweaked.

  • MaxKeepAliveRequests: The maximum number of requests accepted per connection is set out in this directive. The higher this value, the better the server performance. The recommended value is 500.
  • KeepAlive: This directive helps to display a webpage with reduced load time. Creating many connections may reduce the loading time but it also utilizes the resources on the server. Enabling keep-Alive directive helps to overcome this issue. Transfer all those files through a single connection rather than repeatedly opening and closing a new connection.
  • KeepAliveTimeout: The amount of time apache will wait before closing the connection for the subsequent request. Setting keepAliveTimeout to a high value can cause high load server performance problems.

Disable Unnecessary Modules

To extend the functionality and security of Apache you can add an unlimited number of modules. There are numerous Apache modules by default that are actually not needed. You could divert the modules elsewhere, which makes the loading time longer and occupy dedicated server resources. To make our serverless susceptible to threats it is important to disable the unnecessary modules. Mod_imap, mod_include, mod_info, mod_userdir, mod_autoindex are some of the modules that are usually not needed.

Run apache as separate user and group

With the default installation, Apache runs its process with user nobody or daemon. Create Apache User and Group and make an entry in the apache configuration file, so as to tell Apache to run with this new user and restart the service.

groupadd apache 
useradd -d /var/www/ -g apache -s /bin/nologin apache


One of the reasons for Apache’s slow performance may be its inability to handle the load. A multi-processing module will be helpful in such cases. MPM prefork module is part of CentOS 7 and is enabled by default. If mod deflate is enabled, MPM prefork module (shared) will be displayed for better performance. You can set this in the httpd.conf file.

You can add the following lines in the file considering the CPU and RAM allocated for the server.

<IfModule prefork.c>
   StartServers 5
   MinSpareServers 5
   MaxSpareServers 10
   MaxClients 150
   MaxRequestsPerChild 3000

  • StartServers: This sets the number of child server processes created at startup. This can initially be kept as a small number and increases gradually on a high payload server. This helps ensure the correct use of server resources.
  • MinSpareServers: This sets the minimum number of idle child server processes and can be configured for high payload servers.
  • MaxSpareServers: This sets the maximum number of idle child server processes. If this value is exceeded by the number of idle child server processes, the idle processes are killed
  • MaxClients: This is the maximum number of requests that Apache can handle simultaneously. The connection will be queued once this limit is reached.
  • MaxRequestsPerChild: This shows how many requests a child process handles before it ends. The child process will die once this limit has been reached. If the value is set to 0, the process will never die.

DNS Lookups

The main reason for slowing down the Apache web server is the time it takes to perform DNS lookups. In its access.log file, Apache records the full host name of each incoming client connection. Resolving each one takes a long time. The HostnameLookups option allows the DNS lookup to log hostnames instead of the IP address. HostnameLookups is Off by default in Apache.

You can verify this by editing the configuration file of Apache. Make sure that the line HostnameLookups reads:

HostnameLookups Off

When you’re done, save and close the file and restart Apache to reflect changes.

Use Allow and Deny to Restrict access to Directories

We can restrict access to directories in the httpd.conf file with the options “Allow” and “Deny.” In this example, we will secure the root directory by setting the following in the httpd.conf file.

   Options None
   Order deny,allow
   Deny from all   

  • Options None: This option prevents users from enabling any optional features.
  • Order deny, allow: This is the order in which the directives “Deny” and “Allow” are handled. Here it will first “deny” and then “allow.”
  • Deny from all: This denies everyone’s request to the root directory, no one can access the root directory.

Tweak MySQL and PHP settings

Web servers seldom work alone. In most cases, a database server such as MySQL and scripting language support such as PHP to accompany the Apache web server. We have realized why optimizing the database server is equally important to avoid bottlenecks in it, which can slow down the web server. We also improve the performance of PHP pages using a caching or accelerator mechanism such as Zend OPcache.

MySQL is further tweaked by options such as table fragmentation and configuration settings – maximum connections, buffer size, size of the query cache, pool size, etc.


It is very easy to configure Apache for maximum performance. You can experiment with different options and measure the performance of the web server using various tools. We at Skynats have large experience in apache server optimization and you can contact us via Live Chat to know more details.

Liked!! Share the post.

Get Support right now!

Start server management with our 24x7 monitoring and active support team

Can't get what you are looking for?

Available 24x7 for emergency support.