Recompiling Apache With More File Descriptors (RedHat)

Here you can find tutorials and notes for server-side maintenance/configuration

Recompiling Apache With More File Descriptors (RedHat)

Postby lik » Mon May 18, 2009 7:26 am

Recompiling Apache With More File Descriptors on RedHat-like System

Initial/same issue was described at :
To recompile related applications and libraries, such as openssl, apache, imap, PHP etc from source RPMs with increased FD_SETSIZE value, perform the following steps:

1. Make sure that the system allows to open enough files:
Code: Select all
# /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:
Code: Select all
# /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 distributive CD or from your operating system download sites.
3. Edit the __FD_SETSIZE value in typesizes.h and posix_types.h files:
* To find the typesizes.h file, run:
Code: Select all
find /usr/include/ -name typesizes.h

* To find the posix_types.h file, run:
Code: Select all
find /usr/include/ -name posix_types.h

* To edit the __FD_SETSIZE value in a file, run:
Code: Select all
#define __FD_SETSIZE 65536

4. Download the following source RPMs that can be found on your operating system download sites or similar places, you may use RPM search engines such as or
* openssl-*.src.rpm
* httpd-*.src.rpm
* imap-*.src.rpm
* php-*.src.rpm
* libc-client-devel-*.src.rpm (if such RPM is installed)
* curl-*.src.rpm
5. Recompile openssl first. For example:
Code: Select all
# /usr/bin/rpmbuild --rebuild openssl-0.9.7a-35.src.rpm

6. Install the compiled openssl RPM with the following command line:
Code: Select all
# 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 [please use EasyApache scripts on cPanel based servers for/instead further steps]:
Code: Select all
# 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:
Code: Select all
# /usr/bin/rpmbuild --rebuild imap-2002d-3.src.rpm
# rpm -Uvh --force /usr/src/redhat/RPMS/i386/imap-devel-2002d-3.i386.rpm

Code: Select all
# /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:
Code: Select all
# 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

Original :
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Server Side Actions


  • Related topics
    Last post