KB Knowledge Base
How To Update Your Apache Module From Source Code

Article By alexander


img

Update Your Apache Module From Source Code

Introduction

Are you using Apache as a web server? Of course you are. In fact, most of the world also uses it. It's one of the most popular web servers on the planet. It's very flexibly and allows you to add lots of modules to customize it to your needs.

Sometimes you need to upgrade one of those modules due to new features, bugs in the older versions, performance issues and so on. The repository's you've chosen for your Linux distribution does not always have the latest version, so you can't simply run:

yum search mod_dav_svn
or
yum update mod_dav_svn

and get new version or the modules.

In this case you need to build and install the module from source code.

As an example, I will show you how to do that, for the mod_jk module.
(this is an Apache module used to connect the Tomcat servlet container).

Note: it also works for any another module, so remember it's always best to try to understand the concept so you can apply it anytime you need to update a module not in the repository.

Now that you understand what we will be doing in this tutorial let's get started with the update!


What is the current module version?

Use this great utility called strings.

strings - print the strings of printable characters in files.

You need to run somethink like this:

strings /path/to/mod_jk.so | grep -i 'module_name'

Note: in Red Hat like Linux distributive all modules usually stored in /etc/httpd/modules
Note: to show all loaded (built-in or shared) modules right now, run httpd -M
So, run:
[root@server6 ~]# strings /etc/httpd/modules/mod_jk.so | grep -i 'mod_jk'
mod_jk.so
mod_jk.c
mod_jk/1.2.15 <----- this is current module version
logs/mod_jk.log
...



Download And Build

Find the link to the latest module version on official Apache website here: Apache.

Download, unpack and go to module folder:

wget http://apache-mirror.rbc.ru/pub/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz
tar zxvf ./tomcat-connectors-1.2.41-src.tar.gz 
cd ~/tomcat-connectors-1.2.41-src/native

After that find the path to apxs (this is a tool for building and installing extension modules for the Apache) and run script configure which checks for lots of dependencies and create the Makefile.

which apxs
./configure --with-apxs=/usr/sbin/apxs
make

Last two command have long outputs, It will take some time (you will see at the compilation process) and may finish with a failure, which is usually due to a missing required software, so I always recommend you just read and follow the instruction.

If the module was built successful, you can find it with the find command.

find ./ -name mod_jk.so


[root@server6 native]# find ./ -name mod_jk.so
./apache-2.0/mod_jk.so
./apache-2.0/.libs/mod_jk.so



Make Apache backup

In case something goes wrong you can always roll back to an older (obviously) works module, so just remember to make backups:

cp /etc/httpd/modules/mod_jk.so /etc/httpd/modules/mod_jk.so.old



Update

Finally, update module using cp

cp ./native/apache-2.0/mod_jk.so /etc/httpd/modules/mod_jk.so


and restart Apache

service httpd restart


After that go to logs

tail -f /var/log/httpd/mod_jk.log or tail -f /var/log/httpd/error.log


In case you have errors or your website doesn't work, just rollback

cp /etc/httpd/modules/mod_jk.so.old /etc/httpd/modules/mod_jk.so


and restart Apache

service httpd restart


That's all you need to know for your upgrade to be successful! If you have any questions feel free to post them below.




Tags: , , , , , , , , , , , ,

Spin up a VPS server in no time flat

Simple setup. Full root access. Straightforward pricing.

DEPLOY VPS SERVER

Leave a Reply



Feedbacks