How to add a second Apache2 instance to a SLES11 server?

I recently got this question from reader Niyati:

“Can you please guide for installing apache separately without disturbing the current version on sles.. if doing that risks the support issues.. Or any workaround to get the latest release running on sles server.”

I’ll bravely say this with 99% certainty:  Running a second instance of Apache on a SLES server should not compromise your support; especially if you keep it 100% separate.  Besides, if a support person complains, you can always just remove the second instance.

Anyway, here’s a way to install the latest good version of Apache2 (at the time of this writing) on a SLES 11sp1 server that *already* has a SLES-provided Apache2 instance running on it (installed via zypper).

I’m going to run this second instance of Apache on a secondary address, rather than an alternate set of ports; so, I need to bind that secondary IP address.  In my case, my machine is 192.168.1.23/24, and my interface is eth0, so I’ll add .24 for my new instance in real time, like this:

ifconfig eth0:1 192.168.1.24/24

Now, since I’m going to “build my own” Apache, rather than using a pre-built binary (for various reasons), I need to make sure I have the needed support software for compiling and such:

zypper in gcc gcc43 glibc-devel linux-kernel-headers

And it’s time to get the new Apache2 bundle:

mkdir /tmp/apache;cd /tmp/apache
tar zxvf httpd-2.2.19.tar.gz
wget http://www.alliedquotes.com/mirrors/apache//httpd/httpd-2.2.19.tar.gz
cd httpd-2.2.19/

And to get it installed:

./configure
make
make install

Note that since I didn’t specify the installation prefix, it got placed into /usr/local/apache2; so we go there to make some tweaks:

cd /usr/local/apache2/conf
vi httpd.conf

We need to change the Listen statement to reflect the secondary address, like this… Change:

Listen 80
…to…
Listen 192.168.1.24:80

Of course, there’s a ton more you can do with it, but this will get it up and running.

Now, if your *other* instance of Apache is consuming all configured addresses, you’ll need to limit it to just the original IP address rather than 0.0.0.0.

vi /etc/apache2/listen.conf

Change:

Listen 80
…to…
Listen 192.168.1.23:80

Now restart the original instance:

rcapache2 restart

…and a netstat -patune should show 192.168.1.23:80 instead of 0.0.0.0:80

Now restart the new instance:

/usr/local/apache2/bin/apachectl start

…and a netstat -patune should show both 192.168.1.23:80 (for the original instance) and 192.168.1.24:80 (for the new instance).

And with that, you’re up and running with two instances!  You can edit the content of your old instance in /srv/www/htdocs, and the new instance content in /usr/local/apache2/htdocs/.

Now, of course I’m not covering how to automate the startup, or to add SSL, or anything else; I’ve covered those things and many others here in this blog in the past.   Besides, those things are relatively easy to find around the ‘Net… Just like you found this.
😉

Enjoy!

Leave a Comment

Your email address will not be published.