0.安装apache2.2
./configure --prefix=/usr/local/apache --enable-so \--enable-rewrite --with-mpm=workermake && make install
1.安装jdk
tar zxvf jdk-7-linux-i586.gzmv jdk1.7.0 /usr/local/jdk/usr/local/jdk/bin/java --version
2.安装tomcat7.0.37
tar zxvf apache-tomcat-7.0.37.tar.gzmv apache-tomcat-7.0.37 /usr/local/tomcatvim /etc/profileexport JAVA_HOME=/usr/local/jdkexport PATH=$PATH:JAVA_HOME/bin:/usr/local/apache/bin:/usr/local/tomcat/binexport CLASSPATH=$JAVA_HOME/libsource /etc/profile/usr/local/tomcat/bin/catalina.sh startnetstat -an | grep :8080
3.Apache与Tomcat整合
(1).安装jk2
tar zxvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gzcd /root/src/jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/./configure --with-apxs2=/usr/local/apache/bin/apxsmakecd ../build/jk2/apache2//usr/local/apache/bin/apxs -n jk2 -i mod_jk2.so
(2).查看Apache模块
mod_jk2.so
(3).编辑Apache配置文件
vim /usr/local/apache/conf/httpd.confLoadModule jk2_module modules/mod_jk2.so
(4).编辑虚拟主机
NameVirtualHost *:80ServerAdmin admin@free.com DocumentRoot "/data/html" ServerName www.free.com ErrorLog "logs/www.free.com.error.log" CustomLog "logs/www.free.com.access.log" combined Options Indexes FollowSymLinks DirectoryIndex index.html index.jsp index.htm AllowOverride None Order allow,deny Allow from all ServerAdmin admin@free.com DocumentRoot "/data/html/wordpress" ServerName blog.free.com ErrorLog "logs/blog.free.com.error.log" CustomLog "logs/blog.free.com.access.log" combined Options Indexes FollowSymLinks DirectoryIndex index.html index.jsp index.htm AllowOverride None Order allow,deny Allow from all
(5).增加Tomcat的配置文件
cd /usr/local/apache/conf/vim workers2.properties[logger.apache]level=DEBUG[shm]file=/usr/local/apache/logs/shm.filesize=1048576#Example socket channel override port and host.[channel.socket:localhost:8009]port=8009host=127.0.0.1#define the worker[ajp13:localhost:8009]channel=channel.socket:localhost:8009#Uri mapping[uri:/*.jsp][uri:/servlet/*][uri:/*.vm][uri:/*.do]worker=ajp13:localhost:8009
(6).Tomcat配置虚拟主机
(7).测试
cd /data/htmlvim index.jspNow time is :<%=new java.util.Date()%> /usr/local/apache/bin/apachectl -t/usr/local/apache/bin/apachectl -S/usr/local/apache/bin/apachectl start/usr/local/tomcat/bin/catalina.sh start
IE:
注意: 指定HOSTS
效果如下:
Now time is :Tue Feb 26 12:47:51 CST 2013