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)
Depending on your server, you should be looking at Apache, not PHP.
(For RHEL/CentOS) look at /etc/httpd/conf.d/php.ini
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated web pages.
#
LoadModule php5_module modules/libphp5.so
#
# Causes the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
You'll see that your PHP module is modules/libphp5.so
.
AddHandler php5-script .php
tells Apache to run PHP on any file with the extension .php
.
If you are using an RPM based OS it's probably easier to uninstall (assuming you can do that) the current version of PHP, and reinstall the version you are looking for.
rpm -qa | grep php
will show you what version of PHP is currently installed.
Best Answer
You need to do the following:
The above command will display list of available versions for this package. Then select the needed version and do the following.
Example: