How to recompile Apache,PHP and IMAP with increased value of file descriptors larger than FD_SETSIZE (1024) on Debian system?

Article ID: 967 
Last Review: Oct,6 2008
Author:
Last updated by: system APPLIES TO:
  • Parallels Plesk for Linux/Unix

Resolution

NOTE: Since Plesk 8.2.0 up to 900 domains can be hosted on the OS vendor Apache build without  system packages recompilation, described in this article, if Piped Logs feature is enabled on the Plesk server,  see 2066.


Add the following lines to /etc/sysctl.conf:

fs.file-max = 65536

Run the following shell command:
/sbin/sysctl -w fs.file-max=65536

Note that the value fs.file-max can be equal up to 220=1048576).

Add the following line to beginning of /etc/init.d/apache2 and /usr/sbin/apache2ctl:

ulimit -n `cat /proc/sys/fs/file-max`

Change __FD_SETSIZE value in /usr/include/bits/typesizes.h and /usr/include/nptl/bits/typesizes.h files. It should be like:

#define __FD_SETSIZE 65536

Download and rebuild packages:
# apt-get install apt-src
# apt-src --build install openssl
# dpkg -i libssl*.deb openssl*.deb
# apt-src --build install apache2
# dpkg -i libapr*.deb apache2_*.deb apache2-common*.deb apache2-mpm-prefork*.deb apache2-utils*.deb
# cp /opt/psa/suexec/psa-suexec2 /usr/lib/apache2/suexec2 /etc/init.d/apache2 restart
# apt-src --build install libc-client2002edebian
# dpkg -i libc-client-dev_2002edebian1-*.deb libc-client2002edebian*.deb mlock*.deb
# apt-src --build install php4
# dpkg -i `ls *deb|grep php4|grep -v apache-mod`

How to prevent your rebuilt packages from overwriting during the system upgrade you can find in the article:

http://www.debian.org/doc/manuals/apt-howto/ch-apt-get.en.html#s-pin


Subscription for this article changesSubscription for this article changes

Please provide feedback on this article

Did this article help you solve your issue?
Yes
No
Partially
I do not know yet
 
Strongly Agree   Strongly Disagree
  9 8 7 6 5 4 3 2 1
The article is easy to understand
The article is accurate
Additional Comments:
*Please provide us with your email address in case we need to contact you.
* - required fields