wsaer 发表于 2015-8-2 11:24:50

Apache+Jetty整合

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://vincent-nan.blogbus.com/logs/33529295.html

  Jetty国内好像用的人并不多,资料很少。Apache和Jetty整合的更是没有,国外的有一些但大多写的不够清楚。
  最近因为业务需要,需将apache jetty进行整合,研究了一天终于搞定,现将此分享。
  安装包路径:/usr/local/src
  ---安装jdk---
  #chmod u+x jdk-6u11-linux-i586-rpm.bin
#./jdk-6u11-linux-i586-rpm.bin
添加环境变量:
#vi /etc/profile
  添加:
export JAVA_HOME=/usr/java/jdk1.6.0_11
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
---安装Jetty---
Jetty官方网站:http://www.mortbay.org/jetty/
最新版本是 6.1.14
  #unzip jetty-6.1.14.zip
#mv jetty-6.1.14 /usr/local/jetty
#/usr/local/jetty/bin/build_release_bundles.sh /usr/local/jetty
  ---启动Jetty---
Jetty 可以用如下命令启动:
#cd /usr/local/jetty
#java -jar start.jar
访问http://xxx.xxx.xxx.xxx:8080/ 就可以看到Jetty的测试页面
ps:也可以用jetty启动脚本(支持绝对路径)
#/usr/local/jetty/bin/jetty.sh start
---安装Apache---
  Apache官方网站:http://httpd.apache.org/
最新版本是: httpd-2.2.11.tar.gz
#tar zxvfhttpd-2.2.11.tar.gz
#cd cd httpd-2.2.11
#cd srclib/apr
#./configure --prefix=/usr/local/apr --enable-threads --enable-other-child --enable-static
# make && make install
# cd ../apr-util
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ --with-mysql=/usr/local/mysql
# make && make install
#cd ../..
#./configure --prefix=/usr/loacl/apache --enable-modules=so --enable-so --enable-mods-shared=all --enable-cache --enable-file-cache --enable-mem-cache --enable-disk-cache --enable-static-support --enable-static-htpasswd --enable-static-htdigest --enable-static-rotatelogs --enable-static-logresolve --enable-static-htdbm --enable-static-ab --enable-static-checkgid --disable-cgid --disable-cgi --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre
# make && make install
#cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
--- 安装 mod_jk ---
下载地址:http://tomcat.apache.org/download-connectors.cgi
  #tar zxvf tomcat-connectors-1.2.27-src.tar.gz
#cd tomcat-connectors-1.2.27-src
#cd native
#./configure --with-apxs=/usr/local/apache/bin/apxs
#make && make install
  --- 整合 Apache Jetty ---
修改Jetty配置文件:
路径:/usr/local/jetty/etc/jetty.xml
  添加如下内容:

   
      
      127.0.0.1
      8009      
                           
                                 

  或用如下方式启用jetty亦可:
#java -jar start.jar etc/jetty.xml etc/jetty-ajp.xml &(必须在jetty目录下执行)
修改httpd.conf
添加如下内容:

  LoadModule jk_modulemodules/mod_jk.so
  
  
  JkWorkersFile "conf/worker.properties"
  JkLogFile "logs/mod_jk.log"
  JkLogLevel info
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkOptions +ForwardKeySize +ForwardURICompat

JkMount /*.jsp jetty



在httpd.conf同目录下创建worker.properties

其内容为:
worker.list=jetty
  worker.jetty.port=8009
  worker.jetty.host=127.0.0.1
  worker.jetty.type=ajp13
  worker.jetty.lbfactor=1
保存后,重新启动apache和jetty.
测试:
分别访问
http://xxx.xxx.xxx.xxx/
http://xxx.xxx.xxx.xxx/index.jsp
前者会显示apache默认页面: it work
后者会显示jetty错误信息页面
至此Apache Jetty整合完毕..以后会一点一点介绍Jetty的配置文件
最后感谢一下试验中给予帮助一阵风大哥和虎子
宣传下他们的blog:
虎子:http://hi.baidu.com/linux_life/
一阵风:http://chenwenming.cublog.cn
本文转载请注明出处
页: [1]
查看完整版本: Apache+Jetty整合