First, install the JDK1.6.
[Email protected] ~]# chmod +x jdk-6u30-linux-x64-rpm.bin [[email protected] ~]#./jdk-6u30-linux-x64-rpm.bin[[email Protected] ~]# echo "Export Java_home=/usr/java/default" >/etc/profile.d/java.sh[[email protected] ~]#. /etc/profile.d/java.sh
Second, install Tomcat.
[[email protected] ~]# tar xf apache-tomcat-7.0.40.tar.gz -c /usr/local[[ email protected] local]# ln -sv apache-tomcat-7.0.40 tomcat[[email Protected] ~]# vim /etc/profile.d/tomcat.shexport catalina_home=/usr/local/tomcatexport path= $PATH: $CATALINA _home/bin[[email protected] ~]# . /etc/profile.d/tomcat.sh [[email protected] ~]# catalina.sh version #查看版本信息 [[email protected] ~]# vim /usr/local/tomcat/conf/server.xml #添加测试路径 < Engine name= "Catalina" defaulthost= "www.liangshaoqin.com" jvmroute= "Tomcata" > Third, install Apache, first install Apr and apr-util, here skip.
[[email protected] ~]# yum -y install pcre-devel[[email protected] ~]# yum -y install openssl-devel[[email protected] ~]# tar -zxvf Httpd-2.4.10.tar.gz [[email protected] ~]# cd httpd-2.4.10[[email protected] httpd-2.4.10]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd -- enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre -- with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm =event --enable-proxy --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-lbmethod-heartbeat --enable-heartbeat --enable-slotmem-shm -- enable-slotmem-plain --enable-watchdog[[email protected] httpd-2.4.10]# make & & make install[[email protected] ~]# vim /etc/init.d/httpd #为apache提供init脚本, slightly ... 1. Configure Apache to connect with Tomcat via Mod_proxy module to use Mod_proxy with Tomcat instance, Apache has loaded mod_proxy, mod_proxy_http, Mod_proxy_ Modules such as AJP and proxy_balancer_module (used when implementing Tomcat clusters):# /usr/local/apache/bin/httpd -d dump_modules | grep proxy proxy_module (shared) proxy_connect_module (shared) proxy_ftp_module (shared) proxy_http_module (shared) proxy_fcgi_module (shared) proxy_scgi_module (shared) proxy_ajp_module (shared) proxy_balancer_module (shared) proxy_express_module (Shared) 2, add the following to the global configuration segment or virtual host in httpd.conf: proxyvia offproxyrequests OffProxyPreserveHost Off<Proxy *> Require all granted</Proxy> ProxyPass / ajp://172.16.100.1:8009/ ProxyPassReverse / ajp://172.16.100.1:8009/<location / > Require all granted</Location> or allow Apache to integrate with Tomcat's HTTP connector: proxyvia offproxyrequests offproxypass / http:// 172.16.100.1:8080/proxypassreverse / http://172.16.100.1:8080/<proxy *> Require all granted</proxy><location / > require all granted</location>[[email protected] ~]# vim /etc/httpd/httpd.confpidfile "/var/run/httpd.pid" #DocumentRoot "/usr/local/apache/htdocs" #注释此行Include / etc/httpd/extra/httpd-proxy.confloadmodule slotmem_shm_module modules/mod_slotmem_shm.so #取消这两行注释LoadModule slotmem_plain_module modules/mod_slotmem_plain.so[[email protected] ~]# vim /etc/httpd/extra/httpd-proxy.conf<VirtualHost *:80> proxyvia off proxyrequests off proxypreservehost off< Proxy *> require all granted</proxy> proxypass / ajp:// 192.168.1.31:8009/ proxypassreverse / ajp:// 192.168.1.31:8009/<location / > require all granted</Location></VirtualHost>[[email protected] ~]# service HTTPD&NBSP;RESTART3, configure Apache to connect to Tomcat via MOD_JK module [[email protected] ~]# tar xf tomcat-connectors-1.2.40-src.tar.gz [[email protected] ~]# cd tomcat-connectors-1.2.40-src/native/[[email protected] native]# ./configure --with-apxs=/ Usr/local/apache/bin/apxs[[email protected] native]# make && make install[[email protected] ~]# ls /usr/local/apache/ modules/ #检查模块是否已安装成功 [[Email protected] ~]# vim /etc/httpd/httpd.confinclude /etc/httpd/extra/httpd-jk.conf[[email protected] ~]# vim /etc/httpd/extra/ httpd-jk.confloadmodule jk_module modules/mod_jk.sojkworkersfile /etc/httpd/extra/ workers.propertiesjklogfile logs/mod_jk.logjkloglevel debugjkmount /* tomcatajkmount /status/ stat1[[email protected] ~]# vim /etc/ Httpd/extra/workers.propertiesworker.list=tomcata,stat1worker. Tomcata.port=8009worker. Tomcata.host=192.168.1.31worker. Tomcata.type=ajp13worker. Tomcata.lbfactor=1worker.stat1.type = status
APACHE+TOMCAT+JDK installation Configuration