Linux 下apache+tomcat的安装配置以及负载均衡
一、安装apache
a、下载最新源文件httpd-2.2.3.tar.gz。下载地址:http://apache.justdn.org/httpd/httpd-2.2.3.tar.gz
b、编译 apache
1、gzip -d httpd-2.2.3.tar.gz
2、tar xvf httpd-2.2.3.tar
3、./configure --prefix=/export/home/apache2 --enable-module=most --enable-shared=max --enable-so
4、make
5、make install
c、简单配置:编辑httpd.conf,
把#ServerName www.example.com:80项中ServerName前的#号去掉,把xxxxx改成自己的机器全名,212中修改如下
#ServerName www.example.com:80改成ServerName vcmedu:80
把#User daemon改成User tomcat
把#Group daemon改成Group other
如果漏了改它,则apache是没法启动的。
d、启动Apache: #cd /export/home/apache2/bin
#./apachectl start
e、测试Apache是否已经正确运行:http://192.168.1.212/
二、安装tomcat
a、把tomcat_vcmplat目录整个的拷贝到/export/home/tomcat目录下。
chown -fR tomcat:other /export/home/tomcat/tomcat_vcmplat
b、把tomcat5_discovery目录下的bin目录的权限修改为所有者可以具有任何权限。具体命令:
chmod -R 744 bin/
c、配置java home
1、在etc/profile文件里插入以下两行:
JAVA_HOME=/usr/jdk/jdk1.5.0_06 # JAVA_HOME要设置为jdk或jre真正的安装路径
export JAVA_HOME
2、执行reboot命令重启linux系统
第二种配置java home的方法。在catalina.sh文件里添加java home信息。具体语句:JAVA_HOME=/usr/java/jdk
d、修改/tomcat5_discovery/webapps目录以及其下的所有子目录和文件的权限。具体命令:
chmod -R 755 webapps/
e、建立各个tomcat的对立目录
cp /export/home/tomcat/tomcat_vcmplat /export/home/tomcat/tomcat1
rm -fR /export/home/tomcat/tomcat1/webapps
chown tomcat:other /export/home/tomcat/tomcat1
修改tomcat的文件目录,将/export/home/tomcat/tomcat1/conf/server.xml
appBase="webapps"修改为
appBase="/export/home/tomcat/tomcat_vcmplat/webapps"
cp -fR /export/home/tomcat/tomcat1 /export/home/tomcat/tomcat2
修改各个tomcat的端口
tomcat1/conf/server.xml
<Server port="8005" shutdown="SHUTDOWN" debug="0">改为
<Server port="11001" shutdown="SHUTDOWN" debug="0">
<Connector port="80"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="GBK"/>改为
<Connector port="11002"
......
<Connector port="8009"
enableLookups="false" redirectPort="8443" debug="0"
protocol="AJP/1.3" />改为
<Connector port="11003"
......
tomcat2/conf/server.xml
<Server port="8005" shutdown="SHUTDOWN" debug="0">改为
<Server port="12001" shutdown="SHUTDOWN" debug="0">
<Connector port="80"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
debug="0" connectionTimeout="20000"
disableUploadTimeout="true" URIEncoding="GBK"/>改为
<Connector port="12002"
......
<Connector port="8009"
enableLookups="false" r