Hi,
For the people who ask me to install PHP with Tomcat. I will try to explain
as much as possible what i have done. Sorry for my alien english!
I compiled PHP 4.0.3pl1 with SUN JDK 1.3 under Suse 7.0. I use Apache
1.3.12 as WebServer with a personal copy of http.conf, who is running under
the port 15500. Tomcat 3.2 beta 7 is listening under the port 15080 and the
connection between Apache and Tomcat is made under the port 15508 with
mod_jserv.so. I use MySQL 3.22.32. I will explain more in the following,
but I thought it could be important to be known.
You need:
Apache 1.3.12
Tomcat 3.2 beta 7
SUN JDK1.3
MySQL 3.22.32
mod_jserv.so
A- Install libraries you need to compile PHP
A-1 SUN JDK1.3
I choose to make my installation in /home/user/devl/
Download and extract SUN JDK1.3 in the /home/user/devl/jdk1.3
A-2 MySQL 3.22.32 (or newer)
Download and extract MySQL in /home/user/mysql/
Compile MySQL
A-3 Tomcat 3.2 beta 7
Download and install the binaries of Tomcat (if you don't want to compile
tomcat) in /home/user/devl/tomcat
I copy the following classes in the /home/user/devl/tomcat/classes/:
com.sun.xml.*
javax.servlet.http
javax.servlet.jsp
A-4 Apache
I suppose you already have Apache on the server. Make only a local copy of
the httpd.conf in /home/user/apache/conf. You will have to make some folder
more because of the log file (/home/user/apache/var/log/httpd). Normally as
user, you don'T have the rights to copy in log file of Apache per default.
(i suppose!!!).
A-5 mod_jserv
Download and copy mod_jserv.so in /home/user/devl/modules
A-6 PHP 4.0.3.pl1
Download and unpack PHP in /home/user/devl/php-4.0.3pl1/
You will have to make a local copy of apxs and change the following lines:
my $CFG_LIBEXECDIR = q(/home/user/devl/php/lib); # substituted
via APACI install
my $CFG_SYSCONFDIR = q(/home/user/devl/apache/conf); #
substituted via APACI install
Copy the php.ini in /home/user/devl/php/conf/
B- Compile your PHP:
B-1- configure PHP:
In your PHP directory (/home/user/devl/php-4.0.3pl1/), do:
./configure --prefix=/home/user/tmp/
--with-apxs=/home/user/devl/php-4.0.3pl1/apxs
--with-mysql=/home/user/devl/mysql/ --with-java=/home/user/devl/jdk1.3/
--with-servlet=/home/user/devl/tomcat/classes/
--with-config-file-path=/home/user/devl/php/conf/ --enable-debug
--enable-ftp --whithout-gd
B-2- make PHP:
make
make install
B-3- copy the /home/user/devl/php-4.0.3pl1/sapi/servlet/phpsrvlt.jar in the
/home/user/devl/tomcat/lib directory
B-4- copy the /home/user/devl/php-4.0.3pl1/libs/libphp4.so in a directory
where you are sure to find it after that. For example
/home/user/devl/modules/libphp4.so
C- Update Apache httpd.conf
C-1-a Change httpd.conf
Remove all PHP4 commands. Tomcat will execute the php.
#LoadModule php4_module /home/user/devl/modules/libphp4.so
......
#AddModule mod_php4.c
......
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps
C-1-b Add mod_jser.so & path to tomcat.conf
# import tomcat directive
LoadModule jserv_module /home/user/devl/modules/mod_jserv.so
include "/home/user/devl/tomcat/conf/tomcat.conf"
C-2 Change your server.xml, tomcat.conf and web.xml
C-2-a in the /home/user/devl/tomcat/conf/tomcat.conf
###############################################################################
# Apache JServ Configuration File #
###############################################################################
# Note: this file should be appended or included into your httpd.conf
# Tell Apache on win32 to load the Apache JServ communication module
# LoadModule jserv_module modules/ApacheModuleJServ.dll
# Tell Apache on Unix to load the Apache JServ communication module
# For shared object builds only!!!
# @LOAD_OR_NOT@LoadModule jserv_module @LIBEXECDIR@/mod_jserv.so
<IfModule mod_jserv.c>
# Do not edit!
ApJServManual on
ApJServDefaultProtocol ajpv12
ApJServSecretKey DISABLED
ApJServMountCopy on
ApJServLogLevel notice
ApJServLogFile /home/user/devl/apache/var/log/httpd/ApJServLog
### Change if you run tomcat on a different host
ApJServDefaultHost localhost
ApJServDefaultPort 15508
#################### All jsp files will go to tomcat ####################
ApJServMount default /root
AddType text/jsp .jsp
AddHandler jserv-servlet .jsp
AddType text/php .php
AddHandler jserv-servlet .php
...... then the usual stuff ...
</IfModule>
C-2-b in the /home/user/devl/tomcat/conf/server.xml
The important things :
<!-- HttpConnection disabled! We use apache ... -->
<Connector className="org.apache.tomcat.service.SimpleTcpConnector">
<Parameter name="handler"
value="org.apache.tomcat.service.http.HttpConnectionHandler"/>
<Parameter name="port" value="15580"/>
</Connector>
<Connector className="org.apache.tomcat.service.SimpleTcpConnector">
<Parameter name="handler"
value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
<Parameter name="port" value="15508"/>
</Connector>
C-2-c Add the following in the /home/user/devl/tomcat/conf/web.xml
<!-- PHP Configuration -->
<servlet>
<servlet-name>
php
</servlet-name>
<servlet-class>
net.php.servlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
php
</servlet-name>
<url-pattern>
*.php
</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>
php-formatter
</servlet-name>
<servlet-class>
net.php.formatter
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
php-formatter
</servlet-name>
<url-pattern>
*.phps
</url-pattern>
</servlet-mapping>
C-2-d Add the following in the /home/user/devl/tomcat/bin/tomcat.sh
######################################################
#BEGIN Custom settings CLASSPATH for TOMCAT #
######################################################
CLASSPATH=${CLASSPATH}:${TOMCAT_HOME}/lib
######################################################
#END Custom settings CLASSPATH for TOMCAT #
######################################################
D- change .profile file in your home (/home/user)
JAVA_HOME="/home/user/devl/jdk1.3"
export JAVA_HOME
TOMCAT_HOME="/home/user/devl/tomcat"
export TOMCAT_HOME
LD_LIBRARY_PATH="/opt/kde/lib::/home/user/devl/modules"
export LD_LIBRARY_PATH
E-1 Restart Apache
/usr/sbin/httpd -f /home/user/devl/apache/conf/httpd.conf
E-2 Start Tomcat
go in the .../tomcat/bin:
startup.sh
Pray and then try it!!!
Bye,
Olivier