(1)解压安装
1)安装JDK
#./jdk-6u10-rc-bin-b28-linux-i586-21_jul_2008-rpm.bin
运行后会显示一大篇协议,按空格跳过。看到最后出现[yes]时输入yes回车确认。
用文本编辑器打开/etc/profile,在文件的最后添加以下内容:
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export JAVA_HOME CLASSPATH PATH
确定环境变量生效后可以终端中运行:java -version命令测试是否安装成功。
java version "1.6.0_10-rc"
Java(TM) SE Runtime Environment (build 1.6.0_10-rc-b28)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
若出现以上文字那么JDK已经OK了。
2)安装apache
ar -zxvf httpd-2.2.9.tar.gz
程序解压后得到名为:httpd-2.2.9的文件夹。继续运行以下命令:
./configure --prefix=/usr/local/apache --enable-modules=so --enable-mods-shared-all --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer
make
make install
vi /usr/local/apache/conf/httpd.conf命令进行编辑。
DirectoryIndex index.html index.jsp
</IfModule>
<proxy balancer://RHEL5-1>
BalancerMember ajp://192.168.10.6:8009 loadfactor=2 route=jvm1
BalancerMember ajp://192.168.10.5:8009 loadfactor=2 route=jvm2
BalancerMember ajp://192.168.10.160:8009 loadfactor=2 route=jvm3
</proxy>
将文件中以下内容注释掉:
# ServerAdmin [email]webmaster@dummy-host.example.com[/email]
# DocumentRoot "/usr/local/apache/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias [url]www.dummy-host.example.com[/url]
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
# ServerAdmin [email]webmaster@dummy-host2.example.com[/email]
# DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error_log"
# CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
ServerAdmin [email]zhangheng@juwangnet.com[/email]
ServerName localhost
ServerAlias localhost
ProxyPass / balancer://RHEL5-1/ stickysession=jsessionid nofailover=On
ProxyPassReverse / balancer://RHEL5-1/
</VirtualHost>
至此apache安装配置完毕……
<Location /server-status>
SetHandler server-status
Order deny,allow
# Deny from all
Allow from all
</Location>
# ExtendedStatus controls whether Apache will generate "full" status
# information (ExtendedStatus On) or just basic information (ExtendedStatus
# Off) when the "server-status" handler is called. The default is Off.
#
ExtendedStatus On
# Allow remote server configuration reports, with the URL of
# [url]http://servername/server-info[/url] (requires that mod_info.c be loaded).
# Change the ".example.com" to match your domain to enable.
#
<Location /server-info>
SetHandler server-info
Order deny,allow
# Deny from all
Allow from all
</Location>
SetHandler balancer-manager
Order deny,allow
# Deny from all
Allow from all
</Location>
(2)配置Tomcat
先在/usr/local目录中建一个名为tomcat的文件夹,然后在终端中运行:
tar -zxvf apache-tomcat-6.0.18.tar.gz
程序解压后得到名为:apache-tomcat-6.0.18的文件夹,将它复制两份到/usr/local/tomcat目录并重命名为tomcat6-1和tomcat6-2.
进入tomcat6-1目录,修改conf目录下的server.xml文件(以下两个项目不变)
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
找到文件中<Engine name="Catalina" defaultHost="localhost">这一行,将它改为:
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
说明:这里的jvmRoute的值必须对应于httpd.conf文件中最末添加的route的值。
接着在刚才修改的那一行下添加以下内容并保存:
<Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">
- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.BackupManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true" mapSendOptions="6" />
- <Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="3000" />
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4000" autoBind="100" selectorTimeout="100" maxThreads="6" />
- <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector" />
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor" />
<Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor" />
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;" />
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/" watchEnabled="false" />
<ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener" />
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener" />
</Cluster>
端口由8005改为9005,取值随意,不冲突就行。
端口由8080改为9080,取值随意。
端口由8009改为9009,此端口号須与httpd.conf文件中ajp://127.0.0.1:9009的端口一致。
jvmRoute的值应与httpd.conf文件中的第二条route值一致。
端口由4000改为4001,此处端口取值范围在4000~4100,只要与其他tomcat不冲突即可。
最后保存配置。
配置完成!
(3)启动服务
先启动各tomcat:
cd /usr/local/tomcat/tomcat6-1
./startup.sh
cd /usr/local/tomcat/tomcat6-2
./startup.sh
再启动apache:
cd /usr/local/apache/bin
./apachectl start
打开浏览器,通过[url]http://127.0.0.1[/url]来访问一下,应该就会出现大家熟悉的猫猫了。
然后再分别用[url]http://127.0.0.1:8080[/url]和[url]http://127.0.0.1:9080[/url]来访问一下,
它们显示的内容应该是和[url]http://127.0.0.1[/url]一样的,这样就说明apache和tomcat整合成功!
<tomcat-users>
<role rolename=”manager”/>
<role rolename=”admin”/>
<user username= “juwang”password=”1234567″ roles=”manager,admin”/>
</tomcat-users>