Increasing the Number of Domains that Plesk Can Serve

By default, Plesk allows you to manage up to 300 domains on a single server. If you plan to run more sites on a Plesk server, consider switching on the support of piped logs in the Apache web server. This is done on the Tools & Settings > Apache Web Server page of the Server Administration Panel.

Running Apache with piped logs allows you to host up to 900 domains on a server. If you are going to host a larger number of web sites on your server, Apache may fail to work because of a problem with the file descriptors limit. To avoid this, you can recompile Apache with more file descriptors.

Note: Plesk (8.2.0 and later) with piped logs feature enabled can host up to 900 domains without the recompilation of Apache system packages.

Recompiling Apache with More File Descriptors on RedHat-like Systems

To recompile related applications and libraries, such as openssl, apache, imap, PHP etc from source RPMs with more file descriptors, perform the following steps:

  1. Make sure that the system allows you to open enough files:

    # /sbin/sysctl fs.file-max

    fs.file-max = 131072

    If fs.file-max is quite small (several thousands or so), change it in the following way:

    1. Add the following line to /etc/sysctl.conf:

      fs.file-max = 131072

    2. Running the shell command:

      # /sbin/sysctl -w fs.file-max=131072

      Note: If you are running Virtuozzo, you have to adjust the fs.file-max on the hardware node and it will be applied to all VEs.

  2. Make sure you have the glibc-kernheaders and glibc-headers packages installed. They can be taken from the operating system CD or from the download site of your operating system.
  3. Edit the __FD_SETSIZE value in typesizes.h and posix_types.h files:
    • To find the typesizes.h file, run:

      # find /usr/include/ -name typesizes.h

    • To find the posix_types.h file, run:

      # find /usr/include/ -name posix_types.h

    • To edit the __FD_SETSIZE value in a file, run:

      #define __FD_SETSIZE 65536

  4. Download the following source RPMs, which can be found on the download site of your operating system or similar places. You may use RPM search engines such as http://rpm.pbone.net or http://rpmfind.net:
    • openssl-*.src.rpm
    • httpd-*.src.rpm
    • imap-*.src.rpm
    • php-*.src.rpm
    • libc-client-devel-*.src.rpm (if this RPM is installed)
    • curl-*.src.rpm
  5. Recompile openssl first. For example:

    # /usr/bin/rpmbuild --rebuild openssl-0.9.7a-35.src.rpm

  6. Install the compiled openssl RPM with the following command line:

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/openssl-0.9.7a-35.i386.rpm

  7. Recompile and install cURL in the same way.
  8. Recompile and install apache:

    # rpmbuild --rebuild httpd-2.0.51-2.9.src.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/httpd-2.0.51-2.9.i386.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/httpd-devel-2.0.51-2.9.i386.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/mod_ssl-2.0.51-2.9.i386.rpm

  9. Recompile and install the libc-client library which is provided by the imap or libc-client-devel packages (depending on the OS) . Recompile the one that is installed in the system, for example:

    # /usr/bin/rpmbuild --rebuild imap-2002d-3.src.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/imap-devel-2002d-3.i386.rpm

    or

    # /usr/bin/rpmbuild --rebuild libc-client-devel.src.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/libc-client-devel.rpm

  10. Recompile and install PHP, for example:

    # rpmbuild --rebuild php-4.3.10-2.4.src.rpm

    # rpm -Uvh --force /usr/src/redhat/RPMS/i386/php-*

  11. Add the following command to /etc/rc.d/init.d/httpd and /usr/sbin/apachectl startup scripts of apache before other commands:

    ulimit -n 65536

  12. Replace the /usr/sbin/suexec with the one from Plesk:

    # cp /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec

    # /etc/init.d/httpd restart

    For Plesk versions earlier than 7.5:

    # cp /usr/local/psa/suexec/psa-suexec /usr/sbin/suexec

    # chown root:apache /usr/sbin/suexec

    # chmod 4510 /usr/sbin/suexec

    # /etc/init.d/httpd restart

Recompiling Apache with More File Descriptors on Debian Systems

To recompile Apache, PHP and IMAP with a number of file descriptors larger than FD_SETSIZE (1024) on Debian systems:

  1. Add the following line to /etc/sysctl.conf:

    fs.file-max = 65536

  2. Run the following shell command:

    /sbin/sysctl -w fs.file-max=65536

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

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

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

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

    #define __FD_SETSIZE 65536

  5. 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`