安装jdk1.6, 安装tomcat 6, apache版本2.2.3
测试各个服务器是否启动正常
apache启动/停止
[root@bogon run]# service httpd start
[root@bogon run]# service httpd stop
tomcat启动/停止
[root@bogon run]# startup.sh
[root@bogon run]# shutdown.sh
# tail -f catalina.out //查看tomcat输出流
处理tomcat启动问题:
用proxy整合,
方法1:
<VirtualHost *:80>
ServerName www.aaa.com
ProxyPass / http://www.aaa.com:8080/
ProxyPassReverse / http://www.aaa.com:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName oa.aaa.com
ProxyPass / http://oa.aaa.com:8080/
ProxyPassReverse / http://oa.aaa.com:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName sales.aaa.com
ProxyPass / http://sales.aaa.com:8081/
ProxyPassReverse / http://sales.aaa.com:8081/
</VirtualHost>
ProxyPassReverse / ajp://localhost:8009/
现在我们编辑第一个tomcat配置文件,端口为默认的8080
<Engine name="Catalina" defaultHost=www.aaa.com>
<Hostname=www.aaa.comappBase="/www/aaa.com/htdocs"unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"
<Hostname=www.cba.com appBase="/www/cba.com/htdocs"unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"/>
方法2:
在 /usr/local/apache/conf/httpd.conf 末尾加入 :
<Proxy balancer://localCluster>
BalancerMember ajp://localhost:8009
</Proxy>
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^/$ balancer://localCluster/ [P,L,NC]
RewriteRule ^/(.*)$ balancer://localCluster/$1 [P,L,NC]
修改tomcat跟apache知道让web指向同一个目录
#vim /usr/local/tomcat/conf/server.xml
<Host name="localhost" appBase="/usr/local/apache/htdocs"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="." debug="0" workDir="/tmp" reloadable="false"/>