Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Redhat / Fedora Linux Help > php

Forgot Password?
 Redhat / Fedora Linux Help   Help and discussion related to Redhat and Fedora Linux.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 01-07-2005   #1 (permalink)
Just Joined!
 
Join Date: Jan 2005
Location: Vijayawada
Posts: 4
Send a message via Yahoo to niceguy_reddy
php

How can i make tomcat to work with php on redhat linux 9.
niceguy_reddy is offline  


Reply With Quote
Old 01-07-2005   #2 (permalink)
Linux Engineer
 
jledhead's Avatar
 
Join Date: Oct 2004
Location: North Carolina
Posts: 1,030
the easiest way is to have apache be the frontend for tomcat and have apache serve the html and php and then redirect jsp to tomcat.

here is a doc I create once to do this. some parts may not be relavant to you and I used jboss instead of tomcat, but that is easily changed
Quote:
This document is going to attempt to document the setup I undertook for setting up a Redhat server with Apache installed, serving php pages via php, java apps via JBOSS thru apache.
Installs used
Redhat 8 (psyche)
Apache 2.0.40-11.9
PHP 4.2.3-8.0.8
JBOSS 3.2.3.zip
ANT 1.6.1-bin.tar.gz
J2sdk1_4_2_04-linux-i586.rpm
Apt-0.5.5cnc6-fr0.rh80.i386.rpm
MySQL-3.23.58-1.80

also known to work with redhat 9 and all the newer versions of apache up to 2.0.52 and newer versions of php

Got a fresh install of redhat 8 with no http server or redhat httpd server config. then got apt from this website (you can use lynx :
http://dag.wieers.com/packages/apt
apt-get so I could update some packages.

Then you need to apt-get update to update the list of packages

After that you can apt-get upgrade to update all of your packages



Apt-get install mysql will install mysql

Apt-get install postgresql will install postgresql-server

Now we need to configure postgresql to allow connections
Edit the postgresql.conf file and look for this line
tcpip_socket = true
and make sure it is set to true and active.

Save those changes, now edit the file pg_hba.conf and add this at the end
local all all trust
host all all 127.0.0.1 255.255.255.255 trust
local all all ident sameuser

then restart postgresql and it should be ready to go.

Now we need to install apache. I got the latest stable tar from apaches website and compiled as described below:
Extracted the tar in my user folder /home/jledford/ and then
# Cd httpd2.0.49
# ./configure -prefix=/usr/local/apache2 -enable-mods-shared=all

set the prefix (the directory to install apache, /usr/local/apache2) and also
tell it which modules to compile and install. We will tell configure to compile
and install all modules as shared DSO libraries, that way we can easily enable
and disable them in the httpd.conf file.

If configure fails to find the "C" Compiler and quits, run the following command.

apt-get install gcc.

This will download the compiler, library and tools needed.

After this completes, re-run cofigure.

Next run make.
# make

This will compile the source code into executable binaries.

Next run make install.
# make install

this will copy the binaries into the install directory and setup the modules. For configure and make you do not need root access, for make install you will probably need root privileges.

Apache is now install and you should be able to get to it by
# cd /usr/local/apache2
all the apache files and folders should be in here
start and stop apache with a file called apachectl
# cd /usr/local/apache2/bin
# ./apachectl start
to start apache
# ./apachectl stop
to stop apache
# ./apachectl restart
# ./apachectl graceful
both restart apache but graceful does it more gently, either will work though.
Once you have started apache you can test it by going to (on the local machine) http://localhost and it should bring up the apache test page.

Next run make clean to clean up all the temp files that were
generated during the compile and linking processes.

Now we need to get PHP working.
I downloaded the tar for 4.3.2 from www.php.net
Untar that and then get in the dir
# cd /home/jledford/php-4.3.2
# ./configure -with-mysql -with-apxs2=/usr/local/apache2/bin/apxs
# make
# make install
# make clean

# vi /usr/local/apache2/conf/httpd.conf

look for the area where you see all the LoadModule commands and we need to add a new line:
LoadModule php4_module modules/libphp4.so

Again, you will probably need root access for make install.
Now PHP should be installed, you should be able to browse to /usr/local/apache2/modules and see the libphp file there.

Restart apache. Now to test lets create a php info file
#cd /var/www/html
#vi phpinfo.php
this will create a new blank file called phpinfo.php. in the text editor type:
<?php phpinfo(); ?>
and then save the file.

Now open a webbrowser on the server and go to http://localhost/phpinfo.php
If all went well we should see a php test page with all the php configuration information. If you just see a blank page with <?php phpinfo(); ?> then it didn't work.

Now we need to install the mod_jk module.
Go to http://jakarta.apache.org/site/sourceindex.cgi and download the file called jakarta-tomcat-connectors-jk2-src-current.tar.gz

Just put it in your user home dir. We need to unpack it
#tar zxvf jakarta-tomcat-connectors-jk2-src-current.tar.gz
#cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2
#./configure --with-apxs2=/usr/local/apache2/bin/apxs
# make
# cd ../build/jk2/apache2
# /usr/local/apache2/bin/apxs -n jk2 -i mod_jk2.so

now we need apache to load the module so
# vi /usr/local/apache2/conf/httpd.conf
in the LoadModule section we need to add
LoadModule jk2_module modules/mod_jk2.so

Now we need to create a workers2.properties file and put it in the apache conf dir (where httpd.conf is located).
My workers2.properties files looks like this, edit the uri mapping as needed
# only at beginnin. In production uncomment it out
[logger.apache2]
level=DEBUG

[shm]
file=/usr/local/apache2/logs/shm.file
size=1048576

# Example socket channel, override port and host.
[channel.socket:localhost:8009]
port=8009
host=127.0.0.1

# define the worker
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009

# Uri mapping
#[uri:10.0.50.72/*.jsp]
[uri:65.163.172.190/*.jsp]

#worker=ajp13:localhost:8009
group=ajp13:localhost:8009

# Uri mapping
[uri:/*jsp]
#worker=ajp13:localhost:8009
group=ajp13:localhost:8009

#[uri:www:.home.net/*.jsp]
#worker=ajp13:localhost:80

#[uri:www.customer1.it/*.jsp]
#worker=ajp13:localhost:88

#[uri:www.customer2.net/*.jsp]
#worker=ajp13:localhost:88






And the uri is where its going to look inside the jboss dir/ since I want it to serve all jsp to jboss my uri is just /

Now we need to start jboss and restart apache
#/usr/lib/jboss-3.2.3/bin
#./run.sh
to get it to the background hit ctrl-Z and then type bg and hit enter and it will go to the background.
#cd /usr/local/apache2/bin
#./apachectl restart

now open a browser and try http://localhost to make sure it works then try the http://localhost/phpinfo.php and make sure it works then try http://localhost/jmx-console and make sure it loads or type http://localhost/fakefile.jsp and you should get a tomcat error page and not apache. The jmx-console is loaded with the default jboss startup so it should work.
To get apache and jboss starting as a service do the following:
Steps for adding JBOSS & Apache2 as Services in RH9

Configure JBOSS & Apache2 to run as Services and load at boot
JBOSS
1) Copy this file into /etc/rc.d/init.d -- file name is jboss
************************************************** **************************
#!/bin/sh
#
# Startup script for JBOSS, the J2EE EJB Server
#
# chkconfig: 2345 95 15
# description: JBoss is an EJB Server
# processname: jboss
# pidfile: /var/run/jboss.pid
# config: /usr/local/jboss/conf/default/jboss.conf
# logfile: /usr/local/jboss/log/server.log
#
# version 1.0 -
# version 1.1 - kjenks - Start Tomcat, too.
#

# Source function library.
. /etc/rc.d/init.d/functions

# change this according to your own situation
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
export JBOSS_HOME=/usr/lib/jboss-3.2.3
export PATH=$PATH:$JBOSS_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin

RETVAL=0

# See how we were called.
case "$1" in
start)
cd $JBOSS_HOME/bin
echo -n "Starting jboss daemon: "
daemon $JBOSS_HOME/bin/go.sh start
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/jboss
;;
stop)
echo -n "Stopping jboss daemon: "
killproc jboss
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/jboss
;;
restart)
echo -n "Restarting jboss daemon: "
$0 stop
sleep 2
$0 start
;;
esac
************************************************** **************************
2) Make sure your environment is set correctly inside file
3) cd to /etc/rc.d/initd.d/
4) chmod 755 jboss
5) Copy this file into /usr/lib/jboss-3.2.3/bin -- file name is go.sh
************************************************** **************************
#!/bin/sh
#
# Shell script to start and stop integrated JBoss/Jetty

# change this according to your own situation
export JAVA_HOME=/usr/java/j2sdk1.4.2_04
export JBOSS_HOME=/usr/lib/jboss-3.2.3

JAVACMD=$JAVA_HOME/bin/java

# Minimal jar file to get JBoss started.
CLASSPATH=$CLASSPATH:$JBOSS_HOME/bin/run.jar

# Add the tools.jar file so that Tomcat can find the Java compiler.
CLASSPATH="$CLASSPATH:$JAVA_HOME/lib/tools.jar"

if [ "$1" = "start" ] ; then
shift
$JAVACMD $JBOSS_OPTS -classpath $CLASSPATH org.jboss.Main > /dev/null
2>&1 &
echo $! > /var/run/jboss.pid

elif [ "$1" = "stop" ] ; then
shift
kill -15 `cat /var/run/jboss.pid`
rm -rf /var/run/jboss.pid

elif [ "$1" = "run" ] ; then
shift
$JAVACMD $JBOSS_OPTS -classpath $CLASSPATH org.jboss.Main "$@"

else
echo "Usage:"
echo "jboss (start|run|stop)"
echo " start - start jboss in the background"
echo " run - start jboss in the foreground"
echo " stop - stop jboss"
exit 0
fi
************************************************** **************************
6) Make sure your environment is set correctly inside both files
7) cd /usr/lib/jboss-3.2.3/bin
chmod 755 go.sh
9) Type : chkconfig --add jboss && chkconfig --level 35 jboss on
10) Done

Apache2
1) Copy this file into /etc/rc.d/init.d -- file name is httpd
************************************************** **************************
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
pid=$httpd/logs/httpd.pid
prog=httpd
RETVAL=0


# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure. So we just do it the way init scripts
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f $pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
echo $"|fullstatus|graceful|help|configtest}"
exit 1
esac

exit $RETVAL
************************************************** **************************
2) cd to /etc/rc.d/initd.d/
3) chmod 755 httpd
4) Type : chkconfig --add httpd && chkconfig --level 2345 httpd on
5) Done

Reboot to check everything!



After some playing around mysql wasn't properly installed. To make things easier I installed webmin, you can get it from http://www.webmin.com

jledhead is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 05:44 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2