Apache+Tomcat+虚拟机整合

Apache+Tomcat+虚拟机整合

操作系统和软件
答应一好友写的文档。没有采用,哎!!
CentOS4.3
httpd-2.0.59.tar.gz
jakarta-tomcat-5.5.7.tar.gz
jakarta-tomcat-connectors-1.2.15-src.tar.gz
jdk-1_5_0_08-linux-i586-rpm.bin


1,install apache
   
   tar xzvf httpd-2.0.59.tar.gz
   cd httpd-2.0.59
   ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mods-shared=most
   make
   make install
   /usr/local/apache/bin/apachectl start
   ps ax 查看是否有httpd进程
2, install jdk
   
   chmod 755 jdk-1_5_0_08-linux-i586-rpm.bin
   ./jdk-1_5_0_08-linux-i586-rpm.bin
    rpm -ivh jdk-1_5_0_08-linux-i586-rpm
    默认安装在/usr/java/jdk1.5.0_08/
3, install tomcat
   
   tar xzvf jakarta-tomcat-5.5.7.tar.gz
   mv jakarta-tomcat-5.5.7 /usr/local/tomcat
  /usr/local/tomcat/bin/startup.sh 开始
  测试 172.16.103.73:8080能看到小猫不?呵呵
4, Configure JAVA_HOME&&TOMCAT_HOME PATH
   
    vi /etc/profile
    JAVA_HOME=/usr/java/jdk1.5.0_08
    export JAVA_HOME
    PATH=$PATH:/usr/java/jdk1.5.0_01/bin
    export PATH
    export CATALINA_HOME=/usr/local/tomcat
    export TOMCAT_HOME=/usr/local/tomcat
5, install mod_jk(apache和tomcat整合)
  
  tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz
  cd jakarta-tomcat-connectors-1.2.15-src
  cd jk/native/
  ./buildconf.sh
  ./configure --with-apxs=/usr/local/apache/bin/apxs
  make
  cp apache-2.0/mod_jk.so /usr/local/apache/modules/

6, vi /usr/local/apache/conf/httpd.conf
添加
LoadModule jk_module modules/mod_jk.so
JkWorkersFile "/usr/local/apache/conf/workers.properties"
JkLogFile "/var/log/mod_jk2.log"
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat "%w %V %T"
JkLogLevel debug
JkMount /*.jsp worker1

7,添加workers.properties
cd /usr/local/apache/conf
vi workers.properties
worker.list=worker1  
worker.worker1.port=8009  
worker.worker1.host=localhost  
worker.worker1.type=ajp13  
worker.worker1.lbfactor=50  
worker.worker1.cachesize=10  
worker.worker1.cache_timeout=600  
worker.worker1.socket_keepalive=1  
worker.worker1.socket_timeout=300

8, vi /usr/local/tomcat/conf/server.xml
在最后的位置上</host>前添加
<Context path="" docBase="/usr/local/apache/htdocs" debug="0"
        reloadable="true" crossContext="true"/>
      </Host>
docBase="/usr/local/apache/htdocs"该路径于你apache的conf DocumentRoot的路径相同


9,配置虚拟主机
vi /usr/local/apache/conf/httpd.conf
G
去掉 #NameVirtualHost *:80前面的#
在文件最后添加如下

<VirtualHost *:80>
    ServerAdmin lqlboy@XX.com
    DocumentRoot /var/www/jsp.XX.com
    ServerName jsp.xw.com
    ErrorLog logs/jsp-error_log
    CustomLog logs/jsp-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin lqlboy@XX.com
    DocumentRoot /var/www/mail.XX.com
    ServerName mail.XX.com
    ErrorLog logs/mail-error_log
    CustomLog logs/mail-access_log common
</VirtualHost>
vi /usr/local/tomcat/conf/server.xml
在最后的</Host>和</Engine>之间添加相应的host.如下:
<Host name="jsp.xw.com" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
      <Context path="" docBase="/var/www/jsp.XX.com" debug="0"
        reloadable="true" crossContext="true"/>
</Host>
XP下更该本机hosts测试
注:1)在/usr/local/tomcat/conf/server.xml中添加的Host要与apache's conf中的虚拟主机相配对
     2) docBase="/var/www/jsp.XX.com 为jsp页面文件所在文件夹
     3) 每次更改/usr/local/tomcat/conf/server.xml或 apache's conf 别忘记重启服务!!
祝各位兄弟好运气!!
请问当多个虚拟主机时,tomcat里的日志输出怎么处理?
好帖子,正好用上! 谢谢楼主
公司没有跑JSP服务,本人也是一时兴起帮助朋友写写,google+baidu+CU论坛的东西找找拼拼。发现实现Apache+Tomcat整合写的都不是很详细,能完了整合又发现虚拟机实现也是个麻烦事情。前前后后可能用了一天时间。发上无非想让各位兄弟少走弯路。至于再深的东西实在是没有研究!!请见量!!被人也有兴趣进进一步学习。期待有高人指点!!!谢谢!!!
兄弟客气了
翻贴,学习