How to compile and add new module to a running apache?

My web server running apache 2.2.6 (Redhat ES4) with proper configuration. Now I want to add new modules: mod_expires, mod_headers, mod_deflate

I did some search and know there're 2 methods:

1. Use gcc to compile necessary modules from source to .so file, and use LoadModule directive.
2. Recompile apache with some options to keep existing configurations and add new modules.

Could you help me with detail instructions of 2 methods?
Who is Participating?
WodConnect With a Mentor Commented:
1) Build and install a third-party Apache module, say mod_foo.c, into its own DSO outside of the Apache source tree using apxs:

# apxs -c mymodule.c
# apxs -i -a -n mymodule

Then open your httpd.conf file and add mymodule using top LoadModule Directive:

# vi  httpd.conf

Append following line to server config context (this means that the directive may be used in the server configuration files (e.g., httpd.conf), but not within any or containers. It is not allowed in .htaccess files at all).

LoadModule mymodule /usr/lib/httpd/modules/

If you find compile and install procdure difficult to use then try Apachetoolbox ( utility to install your Apache modules easily. See official Apache documentation ( for more information.

2) Compiling apache
there is too much stuff to cover, you should read the link above if you plan to recompile apache
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.