标题:如何在Ubuntu下整合Apache和Tomcat 出处:Felix021 时间:Fri, 10 Oct 2008 13:17:58 +0000 作者:felix021 地址:https://www.felix021.com/blog/read.php?1208 内容: zz from http://ubuntuforums.org/showthread.php?t=219985 原文对应的jdk版本是5, tomcat版本是5 修改成现有版本是jdk6, tomcat5.5 ----- HOWTO : Apache2 + Tomcat5.5 # 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. $ sudo apt-get install apache2-mpm-prefork apache2-common apache2-utils $ sudo apt-get install sun-java6-jdk tomcat5.5 tomcat5.5-admin tomcat5.5-webapps $ sudo apt-get install libapache2-mod-jk 2) Setting up Now let's enable the module and set up the conf file $ 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 $ sudo vi /etc/apache2/workers.properties # Then write following lines 引用 workers.tomcat_home=/usr/share/tomcat5.5 workers.java_home=/usr/lib/jvm/java-6-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 $ /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 (Optional) 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... $ 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! Generated by Bo-blog 2.1.0