# tar tomcat-connectors-1.2.41-src.tar.gz
# cd tomcat-connectors-1.2.41-src/native/
# ./configure --with-apxs=/usr/local/apache/bin/apxs #把mod-jk编译成Apache模块
# make && make install
编辑httpd.conf配置文件,增加如下配置:
vim /usr/local/apache/conf/httpd.conf
#DocumentRoot "/usr/local/apache/htdocs"
#Include /etc/httpd/extra/httpd-proxy.conf
Include /usr/local/apache/conf/extra/httpd-jk.conf
vim /usr/local/apache/conf/extra/workers.properties
worker.list=TomcatA,stat1
worker.TomcatA.port=8009
worker.TomcatA.host=192.168.75.130
worker.TomcatA.type=ajp13
worker.TomcatA.lbfactor=1
worker.stat1.type = status
3、Apache只代理2台后端tomcat的写法,多台和两台的写法类似
vim /usr/local/apache/conf/httpd.conf
#DocumentRoot "/usr/local/apache/htdocs"
#Include /etc/httpd/extra/httpd-proxy.conf
Include /etc/httpd/extra/httpd-jk.conf
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# /etc/init.d/nginx start
Starting nginx: [ OK ]