Wednesday, April 30, 2008

Compiling ServerLimit in Apache 2.x

I had some requirement from my client that required me to set the ServerLimit directive of apache to increase my server limit. So that Apache can serve more number of clients I increased the MaxClients to 500 and after a restart I started receiving warning messages after server start saying to lower my MaxClients limit as ServerLimit was set to 256. One change that has been incorporated in Apache 2.2.x is that ServerLimit cannot be set through configuration files any more for mpm-prefork.

Workaround for this is to compile Apache with increased ServerLimit. So, before you compile, open prefork.c that would be at /server/mpm/prefork/prefork.c
and find the text "DEFAULT_SERVER_LIMIT" then go to the line that says #define DEFAULT_SERVER_LIMIT
there you would find 256 against this directive, change it to the value that you need your ServerLimit to, I changed it to 1000.

Configure, make and make install, and you are all set