# All the modified or additional information will be updated on this post in order for everyone to get alwasys up-to date information. This how to explains you the way to set up apache (http server) + tomcat (servlet container). Tomcat itself can work standalone http server however when we consider about the performance, it's better to use the connector to bind apache and tomcat. (If you really need the performance, RESIN is one of the best servlet container though)
About the connector development of mod-jk2 has been end since 15 November 2004. So please use mod-jk instead. 1) Install the needed package First of all, let's install the packages needed.
Code:
sudo apt-get install apache2-mpm-prefork apache2-common apache2-utils
sudo apt-get install sun-java5-jdk tomcat5 tomcat5-admin tomcat5-webapps
sudo apt-get install libapache2-mod-jk
2) Setting up Now let's enable the module and set up the conf file
Code:
sudo a2enmod
#then type
jk
sudo vim /etc/apache2/mods-enabled/jk.load
#Add the following lines
--
LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so
JkWorkersFile /etc/apache2/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount /jsp-examples worker1
JkMount /jsp-examples/* worker1
JkMount /servlets-examples worker1
JkMount /servlets-examples/* worker1
--
Then create workers file
Code:
sudo vi /etc/apache2/workers.properties
# Then write following lines
--
workers.tomcat_home=/usr/share/tomcat5
workers.java_home=/usr/lib/jvm/java-1.5.0-sun
ps=/
worker.list=worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
--
Ok set up is done. Now try whether everything is ok
Code:
/etc/init.d/apache2 stop
/etc/init.d/tomcat5 stop
/etc/init.d/tomcat5 start
/etc/init.d/apache2 start
# Then access to the page with your browser
http://localhost/servlets-examples/
or
http://localhost/jsp-examples
Option) Server Start up script It's done. If you often change the setting and need to restart the servers, it's better to prepare the script. It's possible to create very nice script but as I'm java developper and I'm not so familier with shell script I made small one...
Code:
vi server.sh
--
#!/bin/bash
/etc/init.d/apache2 stop
/etc/init.d/tomcat5 stop
/etc/init.d/tomcat5 start
/etc/init.d/apache2 start
--
chmod +x server.sh
sudo ./server.sh
Now everything is done!
# Then if you need the environment for the development such as versioning system for your code, please refer to:
Subversion Server + Client
评论排行榜