一、安装APR
创建/usr/local/apr
tar zxvf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr/apr-1.4.5(每一个 ./configure执行完后最好chmod下所有子文件的权限)
make
make install
二、安装apr-util
mkdir /usr/local/apr/util
tar zxvf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr/util/apr-util-1.3.12 --with-apr=/usr/local/apr/apr-1.4.5
三、安装tomcat-native
cd 到tomcat安装目录/bin
tar zxvf tomcat-native-tomcat-native-版本号-src
cd /export/home/process/apache/apache-tomcat-7.0.55/bin/tomcat-native-版本号-src/jni/native
./configure --with-apr=/usr/local/apr/apr-1.4.5 --with-java-home=/usr/jdk/instances/jdk1.6.0 --with-ssl=yes --prefix=/export/home/process/apache/apache-tomcat-7.0.55
make
make install
四、使用openssl生成私钥和证书
openssl genrsa -out privkey.pem 2048
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
生成cacert.pem的参数,倒数第二个name需要是服务器的域名
五、更改tomcat的server.xml配置
<Connector
protocol="org.apache.coyote.http11.Http11AprProtocol"
port="8080" maxThreads="200" clientAuth="false"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/export/home/process/apache/apache-tomcat-7.0.55/conf/cacert.pem"
SSLCertificateKeyFile="/export/home/process/apache/apache-tomcat-7.0.55/conf/privkey.pem"
SSLVerifyClient="none" sslProtocol="TLSv1+TLSv1.1+TLSv1.2"
URIEncoding="GBK" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8080"/>(redirectPort要指向访问的端口)
重启tomcat生效。
配置过程中遇到的问题:
1、安装apr-util和tomcat-native时,需要指定安装的apr目录等,不然会出现make错误
2、生成证书和私钥,直接使用openssl方式