OK, here is an example of how you can run mod_php + mod_php5 on the same server.
NOTE: This covers the installation where you are running mod_php - It won't work for people wanting to use phpsuexec and cgi installs of php.
Disclaimer: You are on your own, if you use or follow any of the following advice and you have any problems, you should be able to work things out for yourself. If you aren't competent in installing apache/php and solving simple related problems, then I would advise that you proceed at your own risk.
Ok,
If you have installed cpanels apache lately, cd to the directory where apache was installed and copy the buildscript to buildscriptphp5
Otherwise, reinstall apache
Code:
# cd /usr/local/src
# wget http://layer1.cpanel.net/buildapache.sea
# sh buildapache.sea
Make sure to select the option to install apache, even if the version is the same.
Then when apache has been reinstalled and is back running, cd to wherever your buildapache is, could be /usr/local/src or /home/cpapachebuild
Code:
# cd buildapache
# cp buildscript buildscriptphp5
Now edit the file buildscriptphp5
Replace the following at around line 24
Code:
REWRITE="--enable-module=rewrite --enable-shared=rewrite"
WITH
Code:
REWRITE="--enable-module=rewrite --enable-shared=rewrite --enable-module=proxy --enable-shared=proxy"
I am assuming here that you will have built apache with mod_rewrite enabled, if you haven't got that line within buildscriptphp5 then add --enable-module=proxy --enable-shared=proxy
to the apache ./configure line lower down the script.
Now, to install apache as you did the last time you ran the buildapache install script, with the new addition of mod_proxy type
Code:
# rm -rf apache_1.3.33 mod_ssl-2.8.22-1.3.33
# ./buildscriptphp5
Assuming all went well and your new apache install has kicked up ok, check the following and add to /usr/local/apache/conf/httpd.conf if you need to
Create a file to hold all the php5 enabled vhosts
Code:
# touch /usr/local/apache/conf/httpd.php5.conf
Edit httpd.conf, make sure these are included and add the Include within your vhost section of httpd.conf
Within the LoadModule config
Code:
LoadModule proxy_module libexec/libproxy.so
Within the AddModule config
Code:
AddModule mod_proxy.c
Then within your Vhost config add
Code:
<IfModule mod_proxy.c>
Include /usr/local/apache/conf/httpd.php5.conf
</IfModule>
Then restart apache, watch for any errors
Code:
# /etc/init.d/httpd graceful
The above will enable mod_proxy into your existing apache installation, which we will use later on to access the second install of apache.
Right, now we will install our second installation of apache, this is where mod_php5 will be installed and running from.
Code:
# cd /usr/local/src
You can use this to install apache if needed, basically just download apache from your apache mirror or use the one that the cpanel script downloaded for you earlier if need be.
Just change the apache url (APACHE variable) or comment the download part out if you copy the files locally.
This will install apache into
/usr/local/apache_php5
using --prefix=/usr/local/apache_php5
Create the apache install script named anything you like and enter the following
Code:
#!/bin/sh
# Install apache for php5 - Make listen to 127.0.0.1 port 8080
# or a port of your choosing.
# Change the apache mirror to where yours is http://httpd.apache.org/download.cgi
APACHE="http://Your_apache_mirror/apache_1.3.33.tar.gz"
if [ ! -e "/usr/local/src/apache-php5" ]; then
mkdir /usr/local/src/apache-php5
fi
cd /usr/local/src/apache-php5
if [ ! -e "/usr/local/src/apache-php5/apache_1.3.33.tar.gz" ]; then
wget -c $APACHE
fi
if [ ! -e "/usr/local/src/apache-php5/mod_ssl-2.8.22-1.3.33" ]; then
wget -c http://www.modssl.org/source/mod_ssl-2.8.22-1.3.33.tar.gz
fi
if [ -d "/usr/local/src/apache-php5/mod_ssl-2.8.22-1.3.33" ]; then
rm -rf /usr/local/src/apache-php5/mod_ssl-2.8.22-1.3.33
fi
if [ -d "/usr/local/src/apache-php5/apache_1.3.33" ]; then
rm -rf /usr/local/src/apache-php5/apache_1.3.33
fi
tar xvzf mod_ssl-2.8.22-1.3.33.tar.gz
tar xvzf apache_1.3.33.tar.gz
cd /usr/local/src/apache-php5/mod_ssl-2.8.22-1.3.33
SSL_BASE=/usr \
CFLAGS="-DEAPI" \
./configure --with-apache=/usr/local/src/apache-php5/apache_1.3.33 \
--prefix=/usr/local/apache_php5 --with-ssl=/usr \
--enable-module=rewrite --enable-shared=rewrite \
--enable-module=ssl --enable-shared=ssl \
--enable-suexec \
--suexec-logfile=/usr/local/apache_php5/logs/suexec_log \
--suexec-caller=nobody \
--suexec-uidmin=100 \
--suexec-gidmin=100 \
--suexec-docroot=/ \
--suexec-userdir=public_html \
--enable-module=expires --enable-shared=expires \
--enable-module=so
cd /usr/local/src/apache-php5/apache_1.3.33
SSL_BASE=/usr \
C_INCLUDE_PATH=/usr/kerberos/include make
C_INCLUDE_PATH=/usr/kerberos/include make certificate
C_INCLUDE_PATH=/usr/kerberos/include make install
This is assuming redhat and that you want SSL to be enabled for this apache install, I haven't enabled ssl and you will need to figure that out if you need it.
If you don't want SSL to be enabled.
Enter the defaults or your details when prompted for the SSL cert details.
Do not say 'y' to having the ssl cert password protected, the one that is generated with 'make certificate' otherwise you will need to type in that pass everytime that you restart this installation of apache.
Now if the install went ok,
edit /usr/local/apache_php5/conf/httpd.conf
Change the Values and add as per the following
Code:
Listen 127.0.0.1:8080
Code:
#
# Port: The port to which the standalone server listens. For
# ports < 1023, you will need httpd to be run as root initially.
#
Port 8080
Code:
<IfDefine SSL>
Listen 8080
Listen 8081
</IfDefine>
Within the Vhost section, add
Code:
NameVirtualHost 127.0.0.1:8080
Assuming all goes well
/usr/local/apache_php5/bin/apachectl start
You should see
Code:
/usr/local/apache_php5/bin/httpd
nobody 25971 0.0 1.0 16288 5616 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
nobody 25972 0.0 1.0 16320 5436 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
nobody 25973 0.0 1.1 16288 5620 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
nobody 25974 0.0 1.1 16288 5628 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
nobody 25975 0.0 1.0 16320 5436 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
nobody 25976 0.0 1.0 16188 5356 ? S 12:40 0:00 \_ /usr/local/apache_php5/bin/httpd
If not, then check the error logs for further clues
/usr/local/apache_php5/logs/error_log