-   Linux - Software (
-   -   Viewing Apache 2.x compile options (HARD_SERVER_LIMIT) (

dazdaz 05-28-2012 07:12 AM

Viewing Apache 2.x compile options (HARD_SERVER_LIMIT)
Hi, how do I view the HARD_SERVER_LIMIT compile time option in httpd 2.x ?

I have tried executing "httpd -V" and also a strings on the binary.

I am curious to discover how my httpd was compiled with which particular options, I understand the default is 256, but I'd like to be more certain.


cliffordw 05-29-2012 02:14 AM

Hi there,

I'm not sure whether "httpd -V" is 100% reliable for this, as someone might have edited src/include/httpd.h instead to change HARD_SERVER_LIMIT, in which case I don't think it will show up in "httpd -V".

One way to confirm this is to change MaxClients to above what you think HARD_SERVER_LIMIT is (i.e. to 257+ if we assume the default HARD_SERVER_LIMIT of 256 is in force), and run "apachectl configtest" or "httpd -t" to test the syntax of the config file. If MaClients is higher than HARD_SERVER_LIMIT you'll get an error message similar to this:


WARNING: MaxClients of 257 exceeds compile time limit of 256 servers,
lowering MaxClients to 256. To increase, please see the
HARD_SERVER_LIMIT define in src/include/httpd.h.


dazdaz 05-29-2012 04:06 AM

I am using Apache 2.2.15.

In which container, prefork.c or worker.c should the MaxClients be modified ?

When I change it within prefork.c, I receive the following message.


:~> sudo apachectl configtest
WARNING: MaxClients of 257 exceeds ServerLimit value of 10 servers,
 lowering MaxClients to 10.  To increase, please see the ServerLimit
Syntax OK

And when I change MaxClients in worker.c, to 5000 I receive no error.

:~> sudo apachectl configtest
Syntax OK

Changing the MaxClients value within both containers does not retun any message about the compile time option HARD_SERVER_LIMIT.

cliffordw 05-29-2012 06:37 AM

Whether you are using prefork or worker MPM depends on your configuration (see One way to tell which is in use, is to run "httpd -V" and look for the "Server MPM" line. Alternately run "httpd -l", and look for prefork.c or worker.c in the output.

If you're changing things in the source, I trust you are recompiling too, otherwise your changes will have no effect. If so, the MPM is specified with the "--with-mpm=MPM" option to the configure command. The default is prefork on Unix.

If you are recompiling, is there a reason for running Apache 2.2.15 and not the latest patch level (2.2.22)?

The correct way to change #define values is to add something like "-D HARD_SERVER_LIMIT=1024" to your CFLAGS environment variable before compiling.

How did you conclude that HARD_SERVER_LIMIT is the problem? As far as I can tell, this setting isn't used in the Apache 2.2 worker or prefork MPMs; they use MAX_SERVER_LIMIT, which is set as follows (as per

There is a hard limit of ServerLimit 20000 compiled into the server (for the prefork MPM 200000). This is intended to avoid nasty effects caused by typos.
Have you checked for a ServerLimit directive in your config files that may be causing the problem? Changing this should solve the problem.

dazdaz 05-31-2012 06:28 AM

Hi, I found what your referring to in the source code.

It would appear that the C definition of HARD_SERVER_LIMIT in 1.x is now called MAX_SERVER_LIMIT in Apache 2.x and the limit is now much higher in 2.x than in 1.x

Ok I finally understood your reply, thank you ! Yes, I will recompile and upgrade. 2.4.2 is the latest current release, not 2.2.15.


$ httpd -l
Compiled in modules:


server/mpm/prefork/prefork.c:#define MAX_SERVER_LIMIT 200000

cliffordw 05-31-2012 11:55 AM

Hi again,

Based on the output you posted earlier, namely:


:~> sudo apachectl configtest
WARNING: MaxClients of 257 exceeds ServerLimit value of 10 servers,
 lowering MaxClients to 10.  To increase, please see the ServerLimit
Syntax OK

It doesn't look like you need to change anything in your source code, as you are nowhere near those limits.

The problem is more likely to just be a configuration problem, with ServerLimit set too low somewhere.

All times are GMT -5. The time now is 09:43 AM.