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

Created:

2016-11-16 13:02:35 UTC

Modified:

2017-04-24 11:59:25 UTC

0

Was this article helpful?


Have more questions?

Submit a request

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

Applicable to:

  • Plesk 10.4 for Linux
  • Plesk 11.0 for Linux
  • Plesk 11.5 for Linux
  • Plesk 12.0 for Linux
  • Plesk 9.5.4 for Linux

Additional Information

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

Resolution

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 of fs.file-max can equal up to 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 the __FD_SETSIZE value in the /usr/include/bits/typesizes.h and /usr/include/nptl/bits/typesizes.h files (if present). It should look like this:

#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 apache2_*.deb apache2*-common*.deb apache2-mpm-prefork*.deb apache2-utils*.deb apache2.*bin*.deb
# cp /opt/psa/suexec/psa-suexec /usr/lib/apache2/suexec
# /etc/init.d/apache2 restart

Continue depending on your operating system:

  • For Debian 4-6:

    # apt-src --build install libc-client2007e
    # dpkg -i libc-client*-dev*.deb libc-client*.deb mlock*.deb
    # useradd –m php-build
    # echo “php-build ALL=(ALL) ALL” >> /etc/sudoers
    # su – php-build
    # apt-src --build install php5
    # exit
    # cd ~php-build
    # dpkg -i php5*.deb libapache2-mod-php5_*.deb

    Note: Creating a "php-build" user is necessary since PHP 5.3.3 on Debian 6.0 is trying to start its own MySQL instance to test MySQL functions after the compilation is complete. However, MySQL will not start under root, thus failing the package build process.

  • For Ubuntu 10.04:

    #apt-src --build install libc-client2007e
    #dpkg -i libc-client2007e-dev*.deb libc-client2007e*.deb mlock*.deb
    #apt-src --build install php5
    #dpkg -i `ls *deb|grep php5 | grep -v apache-mod`

In the following article, you may find a way to prevent your rebuilt packages from overwriting during the system upgrade:

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

Have more questions? Submit a request
Please sign in to leave a comment.