192.168.1.177--->apache http server
192.168.1.178--->apache-tomcat-8.0.32
192.168.1.179--->apache-tomcat-8.0.32
ssh登录192.168.1.177
[root@apachehs opt]# vi /etc/hosts
192.168.1.177 apachehs
[root@apachehs opt]# yum install gcc
[root@apachehs opt]# yum install -y gcc gcc-c++
下面安装apr、apr-util、pcre
[root@apachehs opt]# tar -xvf apr-1.5.2.tar.gz
[root@apachehs opt]# cd apr-1.5.2
[root@apachehs apr-1.5.2]# vi configure
? $RM "$cfgfile"
添加#注释掉这一行
[root@apachehs apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@apachehs apr-1.5.2]# make && make install
[root@apachehs apr-1.5.2]# cd ..
[root@apachehs opt]# tar xvf apr-util-1.5.4.tar.gz
[root@apachehs opt]# cd apr-util-1.5.4
[root@apachehs apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-
apr=/usr/local/apr/bin/apr-1-config
[root@apachehs apr-util-1.5.4]# make && make install
[root@apachehs apr-util-1.5.4]# cd ..
[root@apachehs opt]# unzip pcre-8.38.zip -d /opt/
[root@apachehs opt]# cd pcre-8.38
[root@apachehs pcre-8.38]# vi configure
? $RM "$cfgfile"
添加#注释掉这一行
[root@apachehs pcre-8.38]# ./configure --prefix=/usr/local/pcre
[root@apachehs pcre-8.38]# make && make install
下面安装Apache Http Server
[root@apachehs httpd-2.4.18]# tar xvf httpd-2.4.18.tar.gz
[root@apachehs home]# cd httpd-2.4.18
[root@apachehs httpd-2.4.18]# ./configure --prefix=/home/webserver/apache --with-
apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
[root@apachehs httpd-2.4.18]# make
[root@apachehs httpd-2.4.18]# make install
[root@apachehs httpd-2.4.18]# cd /home/webserver/apache/conf
[root@apachehs conf]# ls
extra httpd.conf magic mime.types original
下面开始配置Apache Http Server
http://httpd.apache.org/docs/2.4/en/mod/mod_proxy_ajp.html
http://httpd.apache.org/docs/2.4/en/mod/
[root@apachehs home]#
vi httpd.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
找到#Listen 80...一行,在下面添加
Listen 192.168.1.177:10080
找到#ServerName ...一行,在下面添加
ServerName 192.168.1.177:10080
在文件的最后加上如下几行:
ProxyRequests Off
<Proxy balancer://clu>
BalancerMember ajp://192.168.1.178:8009 loadfactor=1
BalancerMember ajp://192.168.1.179:8009 loadfactor=1
</Proxy>
[root@apachehs conf]#
vi extra/httpd-vhosts.conf
<VirtualHost *:10080>
# ServerAdmin
[email protected]
# DocumentRoot "/home/webserver/apache/docs/dummy-host.example.com"
ServerName 192.168.1.177:10080
# ServerAlias www.shihuan.example.com
ProxyPass / balancer://clu/ stickysession=JSESSIONID nofailover=On
ProxyPassReverse / balancer://clu/
ErrorLog "logs/cluster-error.log"
CustomLog "logs/custer-access.log" common
</VirtualHost>
[root@apachehs conf]#
vi /etc/httpd/conf/httpd.conf
添加
ServerName 192.168.1.177:10080
[root@apachehs home]# /home/webserver/apache/bin/apachectl -k start
[root@apachehs home]# /home/webserver/apache/bin/apachectl -k stop
----------------------------------------------------------------------------------
ssh登录192.168.1.178
[root@tomcat1 home]# vi /etc/hosts
192.168.1.178 tomcat1
[root@tomcat1 home]# rpm -ivh jdk-7u80-linux-x64.rpm
[root@tomcat1 home]# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export PATH=$JAVA_HOME/bin:$PATH
[root@tomcat1 home]# source /etc/profile
[root@tomcat1 home]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[root@tomcat1 home]# tar xvf apache-tomcat-8.0.32.tar.gz
[root@tomcat1 home]# cd apache-tomcat-8.0.32/conf
[root@tomcat1 conf]# vi server.xml
关注
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
[root@tomcat1 conf]# cd ../bin
[root@tomcat1 bin]# ./startup.sh
[root@tomcat1 bin]# ./shutdown.sh
----------------------------------------------------------------------------------
ssh登录192.168.1.179
[root@tomcat2 home]# vi /etc/hosts
192.168.1.179 tomcat2
[root@tomcat2 home]# rpm -ivh jdk-7u80-linux-x64.rpm
[root@tomcat2 home]# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export PATH=$JAVA_HOME/bin:$PATH
[root@tomcat2 home]# source /etc/profile
[root@tomcat2 home]# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[root@tomcat2 home]# tar xvf apache-tomcat-8.0.32.tar.gz
[root@tomcat2 home]# cd apache-tomcat-8.0.32/conf
[root@tomcat2 conf]# vi server.xml
关注
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
[root@tomcat2 conf]# cd ../bin
[root@tomcat2 bin]# ./startup.sh
[root@tomcat2 bin]# ./shutdown.sh
----------------------------------------------------------------------------------
最后启动测试两个tomcat和apacheserver,启动顺序不能错
[root@
tomcat1 bin]# ./startup.sh
[root@
tomcat2 bin]# ./startup.sh
[root@
apachehs home]# /home/webserver/apache/bin/apachectl -k start
在浏览器的地址栏里输入 http://192.168.1.177:10080/
----------------------------------------------------------------------------------
【注】如果在Windows Server上安装Apche Http Server需要先用管理员身份运行vcredist x64.exe这个文件。
----------------------------------------------------------------------------------
下面3个链接是更加详细的参数设置
http://httpd.apache.org/docs/current/mod/prefork.html
http://wenku.baidu.com/link?url=_iu-OmS_8zh4dsk5QTvQsKLgFBWp27d3XpYk1ggUwkgplEe3D3JIt7wKSsk_I3TWC9Yo9G-oi5GJAcwGSXQzpfoF1u0nV5TLkdPsXIjOite
http://wenku.baidu.com/link?url=sANDvN5HrR3O10OimbYo1JfqdBduEk0Yj_CHigiQTJn_G383v38SEirXSDt0FdENGvJhlWCZ0dmYF1S85NC0EF23XNgFMRelKE8b4chnhiy
http://www.blogjava.net/xiachang88/articles/295969.html