SHARE

Configuring httpd.conf

There are several changes done to the way certain parameters are configured at httpd.conf. You must use your current httpd.conf file as a starting point, and below we will explain what you must change.

Before editing your httpd.conf, you should perform a backup. For instance:

/downloads/xcache-x.y.z# cd /usr/local/apache/conf

/usr/local/apache/conf# cp httpd.conf httpd.conf.2.2

If your previous Apache installation used the “prefork” engine and your new installation uses the “event” engine, you will have to change the parameters listed below (which are just a generic example):

ServerLimit                    2048

StartServers                  512

MinSpareServers             25

MaxSpareServers            50

MaxClients                     2048

MaxRequestsPerChild       100

If your server parameters have the and parameters around them, as in our example, you must either replace “prefork.c” with “event.c” or remove them. Another option is to leave these parameters the way they are and create a new and section, which will hold the new parameters for the “event” engine.

MaxRequestsPerChild must be renamed to ThreadsPerChild and MaxClients must be renamed to MaxRequestWorkers.

The parameters StartServers, MinSpareServers, and MaxSpareServers must be eliminated.

MaxRequestWorkers must specify the maximum number of Apache processes that can be created. This will be the multiplication of ServerLimit by ThreadsPerChild. If ThreadsPerChild (old MaxRequestsPerChild) doesn’t exist, the default value of 25 must be used. The default value of ServerLimit is 6, meaning that by default Apache 2.4 can handle up to 150 simultaneous connections (25 * 6). In our example, as we want each process to handle up to 100 connections and we want a maximum of 2048 connections, we have a problem, as 2048 is not a multiple of 100. If you leave the default value of 25, MaxRequestWorkers (old MaxClients) must be a multiple of 25. In our example, we would have to change MaxRequestWorkers (old MaxClients) to either 2000 or 2100. If we go with 2000, ServerLimit must be set at 20 (2000/100). In your particular case, this value would be different. In summary:

ServerLimit = MaxRequestWorkers / ThreadsPerChild

We also recommend adding the parameter ListenBackLog 5000.

After making these adjustments, our configuration became:

ServerLimit                         20

MaxRequestWorkers             2000

ThreadsPerChild                  100

ListenBackLog                    5000

Of course you can fine-tune these numbers later on, based on the values necessary for your webserver to handle peak traffic.

Let’s now look at other changes you must make.

Change:

LoadModule cgi_module            modules/mod_cgi.so

To:

LoadModule cgid_module          modules/mod_cgid.so

Add the following, if not present yet:

LoadModule authz_host_module    modules/mod_authz_host.so

LoadModule authn_core_module    modules/mod_authn_core.so

LoadModule unixd_module            modules/mod_unixd.so

Configurations such as:

Order allow,deny

Deny from all (or Allow from all)

Must be changed to:

Require all granted

Configurations such as:

Order deny,allow

Deny from all

Must be changed to:

Require all denied

If you have .htaccess files used on your websites with similar parameters, they must be changed too.

Delete or comment lines with the parameter DefaultType.

Delete or comment lines with the parameter NameVirtualHost *.

Phew! Now you are ready to start Apache with apachectl start.

We covered the most common parameters that must be changed. There are several other changes in parameters that may affect your Apache installation. If you see an error message, you must verify its origin, with the aid of the “Upgrading to 2.4 from 2.2” guide available at Apache’s website.

1
2
3

Gabriel Torres is a Brazilian best-selling ICT expert, with 24 books published. He started his online career in 1996, when he launched Clube do Hardware, which is one of the oldest and largest websites about technology in Brazil. He created Hardware Secrets in 1999 to expand his knowledge outside his home country.