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 install

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.



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)


When doing 'make install' you probably installed an apache built from source in directories which should be managed by the distribution.

If you're lucky apache has a 'make uninstall' which should remove all the files it installed. Otherwise, do a make install again and log the output to check which files/directories it installed, and remove those. After you are done, re-install the apache supplied by Ubuntu (apt-get install --reinstall) as some of its files may have been deleted.

Next time, make sure to install it somewhere which isn't managed by the distribution:

./configure --prefix=/usr/local

Or even better "./configure --prefix=/opt/apache-2.2.11" and create symlinks where you need them.

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

The Ubuntu supplied PHP has been compiled against and tested with the Ubuntu supplied apache. If you install a different apache yourself, you will also have to install php yourself.

If you want to use the Ubuntu supplied PHP with a apache compiled with slightly different options, look into building an Ubuntu package from source (apt-get source is a starting point).

  • i thought my ubuntu distro did not come with php pre-installed because i typed "php" into the command line and it did not recognize the bash command. i got the distro on a vps from slicehost (my hosting company). – Tony May 27 '09 at 7:44

warpr explained why you have two apache installs. Typically, when you're using a package-based distribution you should look for a packaged version before you install anything from source.

I wouldn't say you can't use the packaged php5 with a compiled apache, but unless you have a good known reason, use the package. It'll save you time and energy.

As for why apache was automatically installed:

from "aptitude show php5":

This package is a metapackage that, when installed, guarantees that you have at
 least one of the three server-side versions of the PHP5 interpreter installed.

Depends: libapache2-mod-php5 (>= 5.2.6.dfsg.1-3ubuntu4.1) |
         libapache2-mod-php5filter (>= 5.2.6.dfsg.1-3ubuntu4.1) | php5-cgi (>=
         5.2.6.dfsg.1-3ubuntu4.1), php5-common (>= 5.2.6.dfsg.1-3ubuntu4.1)

So what happened is Ubuntu installed the most common PHP interpreter, libapache2-mod-php5, which in turn pulled in apache, and so on.

If you want to install php without installing apache, you could install php5-cgi, which you could then use with other http servers. One way to do this would be:

sudo apt-get install php5-cgi php5

which would use php5-cgi as the depends for the php5 package.


Look for the httpd file.

In many linux systems its located here:


Try editing that file and seeing if you are starting up 2 versions of the apache http daemon. Delete the lines starting the one you dont want.

  • 2 versions are installed, not running. i want to remove an installation – Tony May 27 '09 at 5:56
  • You should edit the title of your question then. It says "Two versions of Apache RUNNING on ubuntu. – Alan May 27 '09 at 17:26

I don't see a good reason given why you would compile your own apache. One good reason to not do this is that it makes maintenance a lot harder. Security patching is no joke when you have to compile 5 different pieces of software to patch. And that is supposing you actually know about the security vulnerability. This is why we use packages and the Ubuntu supplied apache in this case.

So, keeping in mind that you probably shouldn't do this, there's one trick nobody has mentioned. If you really really want to use your own compiled apache with other Ubuntu packages, use the "equivs" package. From the description:

Another use is to circumvent dependency checking. If a package P is not installed on the system, packages that depend on P cannot normally be installed. However, if functionality equivalent to P is known to be installed, this tool can be used to trick the Debian package management system into believing that package P is actually installed. NOTE: this should be considered a crude hack to work around awkward situations, not a normal solution. If you use equivs to work around bugs in other Debian packages, you should also file bug reports against those packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.