Linux : Install file_cache_module.so on CentOS/RHEL6

By | June 14, 2014

Since CentOS/RedHat Enterprise Linux 6, “mod_file_cache”, commonly referred as “MMapFile” too is no longer provided with Apache binary. File Cache module statically map file pages into memory.

This module is still experimental according to Apache documentation, which may explain why it’s not included, even though it was included in CentOS/RHEL5.

You may get the following error output trying to reload or restart apache when you have a “MMapFile” statement in your configuration and the module missing from your system :

Invalid command ‘MMapFile’, perhaps misspelled or defined by a module not included in the server configuration

You can add the module to your system keeping the stock binary package and avoid mixing 3rd party RPM repository. Just follow these steps.

1. Install the required development packages :

yum install httpd-devel gcc

2. Get your current running Apache version :

rpm -qv httpd

(CentOS/RHEL 6.5 should output the following : httpd-2.2.15-30.el6.centos.x86_64)

3. Get the Apache source matching your running version from the archive download repository :

http://archive.apache.org/dist/httpd/

(this example would require the following package : http://archive.apache.org/dist/httpd/httpd-2.2.15.tar.gz)

cd /usr/local/src
wget http://archive.apache.org/dist/httpd/httpd-2.2.15.tar.gz

4. Go to the module directory :

cd httpd-2.2.15/modules/cache

5. Build the module :

apxs -i -a -c mod_file_cache.c

All done, the module has been compiled and added in httpd.conf.

6. Check your configuration :

service httpd configtest

If no error output, then reload the configuration :

service httpd reload

NOTE : Optionally if you do not need them anymore, you may now remove the development packages and their dependencies we’ve installed in the beginning as followed :

yum remove gcc httpd-devel apr-devel apr-util-devel cyrus-sasl-devel expat-devel openldap-devel