|
本帖最后由 破晓 于 2018-10-10 10:20 编辑
安装准备1.tomcat 8.5以上,本文用的tomcat 9
2.Centos7 系统
3.tomcat配置pem证书,需要arp支持,所有在centos 7中先安装
4.openssl 可以到 https://www.openssl.org/source 下载最新版本
5.apr,apr-util 可以到国内镜像下载最新版本:http://mirror.bit.edu.cn/apache/apr
6.tomcat-native 到 http://mirrors.tuna.tsinghua.edu ... -connectors/native/ 下载最新版本或者使用tomcat bin下面的压缩包
安装依赖- //配置gcc依赖
- yum install gcc
- cd /home/soft
- //安装openssl
- wget https://www.openssl.org/source/openssl-1.1.1-pre8.tar.gz
- tar -zxvf openssl-1.1.1-pre8.tar.gz
- cd openssl-1.1.1-pre8
- ./config --prefix=/usr/local/openssl
- make && make install
复制代码- //安装apr
- cd ../
- wget http://mirror.bit.edu.cn/apache/apr/apr-1.6.3.tar.gz
- tar -zxvf apr-1.6.3.tar.gz
- cd apr-1.6.3
- ./configure --prefix=/usr/local/apr
- make && make install
复制代码- //安装apr-util
- cd ../
- wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
- tar -zxvf apr-util-1.6.1.tar.gz
- cd apr-util-1.6.1
- ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- make && make install
复制代码 安装apr-util可能会报一个异常:
- xml/apr_xml.c:35:19: error: expat.h: No such file or directory
复制代码 安装expat库试试。
- //安装tomcat-native
- cd ../
- wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-connectors/native/1.2.17/source/tomcat-native-1.2.17-src.tar.gz
- tar -zxvf tomcat-native-1.2.17-src.tar.gz
- cd tomcat-native-1.2.17-src/native
- ./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
- make && make install
复制代码 如果没配置JDK环境变量还要加上JDK环境变量配置
在末尾添加
- export JAVA_HOME=/usr/java/jdk1.8.0_121
- export JRE_HOME=${JAVA_HOME}/jre
- export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
- export PATH=${JAVA_HOME}/bin:$PATH
复制代码
然后执行
然后配置tomcat 配置文件 conf/server.xml
- <Connector port="80" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="443" />
- <Connector port="443" protocol="org.apache.coyote.http11.Http11AprProtocol"
- maxThreads="150" SSLEnabled="true" >
- <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
- <SSLHostConfig>
- <Certificate certificateKeyFile="/etc/letsencrypt/live/code2048.net/privkey.pem"
- certificateFile="/etc/letsencrypt/live/code2048.net/cert.pem"
- certificateChainFile="/etc/letsencrypt/live/code2048.net/chain.pem"
- type="RSA" />
- </SSLHostConfig>
- </Connector>
- <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
复制代码 默认8443端口,使用443 端口在浏览器不用输端口号就和80端口一样
同时防火墙要把443端口开放
配置完启动Tomcat
来源:http://blog.airmyth.com/447.html
|
|