ubuntu整合apache和tomcat

ubuntu整合apache和tomcat
 
ubuntu:12.04.1 
apache:2 
tomcat:7.0.27 
版本号不同也没关系了,配置都是一样的。 
 
1、安装apache 
引用
aptitude install apache2
 
2、安装tomcat 
直接 下载压缩文件,这个看个人的使用方法,我比较喜欢下载压缩文件。 
3、载apache连接tomcat的一个插件libapache2-mod-jk 
引用
apt-get install libapache2-mod-jk
 
4、开启jk模组及其配置 
引用
a2enmod jk
 
如果还要 启用include和rewrite模块,则执行下面的命令 
引用
a2enmod include 
a2enmod rewrite
 
5、配置apache 
修改/etc/apache2/sites-available/default文件,增加以下行 
引用
JKMount /* ajp13_worker
 
6、修改/etc/libapache2-mod-jk/worker.properties文件 
引用
workers.tomcat_home=指定到本地的tomcat路径 
workers.java_home=/home/steven/tools/jdk1.6.0_25
 
7、开启tomcat的ajp模块 
引用
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


自己做点说明。
个人觉得ubuntu安装的apache跟其他操作系统安装有很大的区别。
其安装目录默认安装在/etc/apache2
看如下图。其配置文件为apache2.conf ,,不在是httpd.conf这个区别于其他操作系统安装的apache


下面是自己配置的一个apache url请求转发。
<VirtualHost *:80>    
ServerName www.xxx.com     
ProxyRequests Off 
ProxyVia full  
ProxyPass / http://127.0.0.1:8080/c9/
ProxyPassReverse / http://127.0.0.1:8080/c9/
        ProxyPassReverseCookiePath /c9 /                        
</VirtualHost>
所有www.xxx.com从这个网址过来的,都通过请求转发到我们的 http://127.0.0.1:8080/c9/  这个项目。
ProxyPassReverseCookiePath /c9 /     这个作用就是为了防止,apache在请求转发过程中session丢失。(通过apache访问Tomcat,session丢失的问题)
NOTE Don’t forget the trailing / at the end of the mapped URL for ProxyPass and ProxyPassReverse; otherwise your traffic will get redirected to invalid URLs like http://mydomain.comblahblah, instead of /blahblah.

<VirtualHost *:80>    
ServerName www.csart.net  
ServerAlias csart.net   
ProxyRequests Off 
ProxyVia full  
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>


Linux系统为Ubuntu

一、Start Apache 2 Server /启动apache服务

# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start

二、 Restart Apache 2 Server /重启apache服务

# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart

三、Stop Apache 2 Server /停止apache服务

# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop


对自己在补充一点。
<VirtualHost *:80>    
ServerName www.c9cn.com
       ServerAlias c9cn.com
       RewriteEngine on
ProxyRequests Off 
ProxyVia full  
       ProxyPass /s/ http://127.0.0.1:8080/s/                      
 //页面通过不同的路径访问,访问到不同的项目,如www.c9cnxxx.com/s/  访问solr
       ProxyPassReverse /s/ http://127.0.0.1:8080/s/


        ProxyPass / http://127.0.0.1:8080/c9/
        ProxyPassReverse / http://127.0.0.1:8080/c9/   


       ProxyPassReverseCookiePath /c9 /
</VirtualHost>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值