Thursday, October 10, 2013

How-To: Install New Module or Upgrade Apache Http Server from Source

Did you install your Apache HTTP server from source and later on wanted to add a new module to it that you did not install previously. Well, you're not alone my dear and there's a nice and clean way to achieve this. We will discuss about this How-To in this post.

Start by locating the config.nice file in the build directory of your existing installation of the Apache server. This will contain the exact configure command line that you used to configure the source tree when you previously installed your server from source packages.

For example, this is the original configure command (stored in build/config.nice) when http server was first installed from source:
 #! /bin/sh  
 #  
 # Created by configure  
 "./configure" \  
 "--enable-file-cache" \  
 "--enable-cache" \  
 "--enable-disk-cache" \  
 "--enable-mem-cache" \  
 "--enable-expires" \  
 "--enable-headers" \  
 "--enable-usertrack" \  
 "--enable-cgi" \  
 "--enable-vhost-alias" \  
 "--enable-so" \  
 "--enable-mods-shared=all" \  
 "--enable-access=static" \  
 "--enable-mime=static" \  
 "--enable-setenvif=static" \  
 "--enable-dir=static" \  
 "--enable-ssl=yes" \  
 "--with-apr=/usr/local/apr/" \  
 "--prefix=/usr/local/apache-httpd" \  
 "--with-pcre=/usr/local/pcre" \  
 "$@"  
Now, let's say that you want to enable the rewrite module. What you need to do is locate the httpd-NN directory where you extracted the zip file when you first downloaded it. If it is not available or you've deleted it, then download that version again (Please see below NOTE section if the same version is not available).

Then, copy the config.nice file from the build directory of your existing httpd installation. Paste it on to the source tree of the extracted httpd-NN directory. Please note that, NN in httpd-NN means the version number of the server.

Now, after copying the existing config.nice file, add the "--enable-rewrite" \ directive at the end of the file like this:
 #! /bin/sh  
 #  
 # Created by configure  
 "./configure" \  
 "--enable-file-cache" \  
 "--enable-cache" \  
 "--enable-disk-cache" \  
 "--enable-mem-cache" \  
 "--enable-expires" \  
 "--enable-headers" \  
 "--enable-usertrack" \  
 "--enable-cgi" \  
 "--enable-vhost-alias" \  
 "--enable-so" \  
 "--enable-mods-shared=all" \  
 "--enable-access=static" \  
 "--enable-mime=static" \  
 "--enable-setenvif=static" \  
 "--enable-dir=static" \  
 "--enable-ssl=yes" \  
 "--with-apr=/usr/local/apr/" \  
 "--prefix=/usr/local/apache-httpd" \  
 "--with-pcre=/usr/local/pcre" \  
 "--enable-rewrite" \  
 "$@"  
At the end, execute the following commands in the given order:
 $ ./config.nice  
 $ make  
 $ sudo make install  
 $ PREFIX/bin/apachectl -k graceful-stop  
 $ PREFIX/bin/apachectl -k start  
The rewrite module should be successfully enabled now.

You can enable other modules like ssl, etc., in this manner. Also make note of the fact that you may be required to manually install dependencies related to the module that you want to enable. For example, to enable ssl, you need to have openssl installed on your system as a dependency.

Note: If you cannot find the exact version of the httpd server that you installed previously, you can alternatively download a new minor version. For example, if your original version was 2.2.55, you can now download version 2.2.57 and copy the existing config.nice file in the source tree of httpd-2.2.57 and then run the above mentioned commands. You should be able to get the same results, i.e., your modules should get installed without any error.


If you want to do a fresh installation of the apache http server, then checkout this post.

Thank You!!!

No comments:

Post a Comment