ubuntu整合apache和tomcat

喜欢ヅ旅行 2022-08-24 00:50 283阅读 0赞

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模块

引用

自己做点说明。

个人觉得ubuntu安装的apache跟其他操作系统安装有很大的区别。

其安装目录默认安装在/etc/apache2

看如下图。其配置文件为apache2.conf ,,不在是httpd.conf这个区别于其他操作系统安装的apache

SouthEast

下面是自己配置的一个apache url请求转发。


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 /

所有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.



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/

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

对自己在补充一点。


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 /

发表评论

表情:
评论列表 (有 0 条评论,283人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Linux环境下整合ApacheTomcat

    1、前言: 在开发项目的时候,因为目前接触的大多都是一些小项目,都是通过php就完成了后端的开发。但是这次因为需求,采用了java编写后端,因此就设计到了Apache和T