centos环境下整合apache + tomcat + ssl
#安装环境
32位 CentOS 6.3 或 32位 CentOS 6.0
#------------------------------------------------------
#软件列表
#------------------------------------------------------
jdk-6u26-linux-i586-rpm.bin
apache-tomcat-6.0.37.tar.gz
tomcat-connectors-1.2.37-src.tar.gz
#确认是否安装jdk,没安装则安装jdk
#------------------------------------------------------------------
chmod 755 jdk-6u26-linux-i586-rpm.bin
./jdk-6u26-linux-i586-rpm.bin
vi /etc/profile
#在文件最下面增加下段代码
export JAVA_HOME=/usr/java/jdk1.6.0_26
export JAVA_BIN=/usr/java/jdk1.6.0_26/bin
export PATH=$JAVA_HOME/bin:$PATH:
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#退出并保存
source /etc/profile
#测试
java -version
#确认是否安装apache,没安装则安装apache
#------------------------------------------------------------------
步骤略,详见 http://wxb-j2ee.iteye.com/blog/2028806【svn】安装说明apache章节.
#确认是否安装tomcat,没安装则安装tomcat
#------------------------------------------------------------------
tar -xvf apache-tomcat-6.0.37.tar.gz
mv apache-tomcat-6.0.37 /usr/local/
cd /usr/local/
mv apache-tomcat-6.0.37/ tomcat
#编译生成mod_jk并配置apache
#------------------------------------------------------------------
tar -xvf tomcat-connectors-1.2.37-src.tar.gz
cd /home/soft/tomcat-connectors-1.2.37-src/native/
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
cd apache-2.0/
cp mod_jk.so /usr/local/apache2/modules/
cd /usr/local/apache2/conf/
#增加以下代码内容
JkWorkersFile /usr/local/apache2/conf/workers.properties
# Where to put jk logs
JkLogFile /usr/local/apache2/logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# 将所有请求通过local过滤送给Tomcat,让Tomcat来处理,html\jpg\gif除外
JkAutoAlias /usr/local/tomcat/webapps
# All requests go to local by default
JkMount /* local
# Serve html, jpg and gif using httpd
JkUnMount /*.html local
JkUnMount /*.jpg local
JkUnMount /*.gif local
#测试 将所有 servlet 和 jsp 请求通过ajp13的协议送给Tomcat,让Tomcat来处理
#JkMount /examples/servlets/servlet/* test
#JkMount /*.jsp test
#保存并退出
#增加以下代码内容
# Defining a worker named local,test and of type ajp13
worker.list=local,test
# Set properties for test
worker.test.type=ajp13
worker.test.host=localhost
worker.test.port=8009
worker.test.lbfactor=50
# Set properties for local
worker.local.type=ajp13
worker.local.host=localhost
worker.local.port=8009
worker.local.lbfactor=50
worker.local.cachesize=10
worker.local.cache_timeout=600
worker.local.socket_keepalive=1
worker.local.socket_timeout=300
#保存并退出
修改apache httpd.conf
#更改apache默认路径为指定目录路径
DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
#改为
DocumentRoot "/techcenter/web"
<Directory "/techcenter/web">
#找到DirectoryIndex index.php index.html 修改为下段代码
<IfModule dir_module>
DirectoryIndex index.php index.html index.jsp
</IfModule>
#在文件最下面增加下段代码
LoadModule jk_module modules/mod_jk.so
Include /usr/local/apache2/conf/mod_jk.conf
#找到下面一行代码,并打开下行代码
Include conf/extra/httpd-vhosts.conf
#配置整合ssl
vi httpd-ssl.conf
#找到<VirtualHost _default_:443>在下面修改相应代码
DocumentRoot "/techcenter/web"
ServerName localhost:443
ServerAdmin admin@localhost
ErrorLog "/usr/local/apache2/logs/error_log"
TransferLog "/usr/local/apache2/logs/access_log"
#保存并退出
vi httpd-vhosts.conf
#删除示例代码,在最下面修改或增加下段代码
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/techcenter/web"
ServerName localhost:80
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>
#保存并退出
-------------------------------------------------------------------------------------------
整合apache + tomcat + ssl完毕!配置了ssl,http协议请求方式依旧可以使用。测试时分别http://IP/ 与 https://IP/。