Ubuntu – I have two versions of apache running on Ubuntu, how can I remove one

apache-2.2installationPHPUbuntu

I installed apache on ubuntu by doing the following:

sudo -i
cd /usr/local/src
wget http://apache.mirrors.tds.net/httpd/httpd-2.2.11.tar.gz
tar -xvf httpd-2.2.11.tar.gz
cd httpd-2.11.9
./configure --enable-layout=Debian --enable-deflate --enable-proxy --enable-proxy-html --enable-proxy-http --enable-proxy-balancer --enable-rewrite --enable-cache --enable-mem-cache --enable-ssl --enable-headers --enable-mods-shared=most
make
make install
exit

Then I installed php5 by doing the following:

sudo apt-get install php5

Now I have two versions of apache:

tony@bootsy/etc/apache2 $ apachectl -v       
Server version: Apache/2.2.11 (Unix)
Server built:   May 26 2009 21:57:13
  tony@bootsy/etc/apache2 $ apache2ctl -v
Server version: Apache/2.2.8 (Ubuntu)
Server built:   Mar 10 2009 18:09:51

I tried apt-get remove, apt-get autoremove, etc. They all still leave traces of apache. I obviously only want one version of apache running…but I am also not sure which…would it be best to run Apache/2.2.8 (Ubuntu)? Regardless, how can I remove the other version?

It is not obvious how to install php5 without apache… which I think is crazy.

Thanks!

Best Answer

The first thing to be aware of is that you didn't just install two instances of apache, you actually used two different installation mechanisms - one by compiling, the other by using the resident dpkg (called via apt) mechanism.

Neither method is more (or less) valid than the other, and, one can't categorically state you have to use only one method; but you've already identified the first issue with using two different mechanisms - your package manager (dpkg) doesn't know anything about your hand-compiled installation.

The reason you ended up with a version of apache from the apt-get install php5, is that built into the php5 package is a number of dependencies. You can query the packaging database for the dependencies with dpkg-query:

# dpkg-query -W -f='${Package} ${Version}\t${Maintainer}\n${Depends}\n' php5

php5 5.2.4-2ubuntu5.6   Ubuntu Core Developers <ubuntu-develdiscuss@lists.ubuntu.com>
libapache2-mod-php5 (>= 5.2.4-2ubuntu5.6) | php5-cgi (>= 5.2.4-2ubuntu5.6), 
  php5-common (>= 5.2.4-2ubuntu5.6)

You'll see a link to libapache2-mod-php5, which in turn references the apache that was installed.

As to removal - apt-get remove apache2 will remove the version of apache2 installed by the package manager, but it will not touch (nor would you want it to) files that have been manually added - those will require your careful inspection and analysis of the system.

If you are lucky, the make file that did the install when you typed make install

also has a make remove

In the case of apache2/httpd - you don't have that luxury, but that's a fairly clean install, as installs go, so you should be able to identify the directory that you installed in, and an

rm -rf /usr/local/apache2 (or wherever you installed apache)

should remove most files placed onto your system.

If you don't have a clean install - you'll need to search for the files that were installed on your system.

One typical way of determining what has been added to your system after an installation done manually (works for everything, not just autoconfig installs) is to run the command:

find / -cmin -2 2>/dev/null | egrep -v '^(/proc|/sys)'

You can then use the output of that command to provide you with a list of files that should be considered for removal.

I realize this isn't a soup-nuts guide to removing what has been placed on your system, but the challenges you are experiencing are precisely why people work so hard to use package managers to manage their system (which, in addition to clean adding/removing of files, also provides a number of other useful benefits, such as binary-verification to see if anything has been modified)

Related Topic