Centos7 安装 tomcat 服务

### 一、下载tomcat压缩包,解压并上传到服务器 [到官网下载](https://tomcat.apache.org/download-90.cgi) ### 二、配置端口号 #### 1、修改 tomcat 的 \`server.xml\` 文件 \`\`\`shell vim apache-tomcat-8.5.39/conf/server.xml \`\`\` 修改以下配置(如果要让http跳转到https,80端口配置要在443端口配置后面。) \`\`\`vim <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" scheme="https" secure="true" keystoreFile="PFX.pfx" keystoreType="PKCS12" keystorePass="PASSWORD" clientAuth="false" SSLProtocol="TLSv1 TLSv1.1 TLSv1.2" ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256" URIEncoding="UTF-8" /> <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" URIEncoding="UTF-8" /> \`\`\` ##### https 证书可以在阿里云免费获取([快捷通道](https://common-buy.aliyun.com/?spm=5176.2020520163.cas.3.2bbc56a7XwPQH1&commodityCode=cas&request={"cer_type":"starter_wc","brand":"geotrust","domain_type":"all","domain_num":1,"order_num":1,"ord_time":"1:Year"}&commodityParams={"oldCertId":2259138,"oldOrderId":2117267})) ![阿里云免费证书](/C/Users/Administrator/SiteResources/uploads/2020/04/QQ图片20200407151802.png) ### 三、添加 tomcat 到系统服务 #### 1、修改 tomcat 的 \`catalina.sh\` 文件 \`\`\`shell vim apache-tomcat-8.5.39/bin/catalina.sh #添加: CATALINA_PID="$CATALINA_BASE/tomcat.pid" \`\`\` #### 2、\`/usr/lib/systemd/system\` 下创建文件 \`tomcat.service\` \`\`\`vim [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/home/tomcat/bin/startup.sh ExecStop=/home/tomcat/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target \`\`\` #### 3、启动 tomcat \`\`\`shell # 开机启动 systemctl enable tomcat # 开始/停止/重启 systemctl start/stop/restart tomcat \`\`\` ### 三、常见问题 #### 1、tomcat 文件权限问题 到tomcat中\`bin\`目录下面,修改\`catalina.sh\`文件 \`\`\`vim # Set UMASK unless it has been overridden if [ -z "$UMASK" ]; then UMASK="0027" # 把0027改为0022 fi umask $UMASK \`\`\`

更多文章

为什么视频压缩后不能在网页上播放 2020-04-13  11:00:25 怎么处理不合脚的鞋 2020-04-13  11:00:11 Windows 启用 IIS 并配置 PHP 环境 2020-04-13  10:59:57 Centos7 安装 tomcat 服务 2020-04-13  10:54:34 Python xlrd 模块获取 Excel 文件内容 2020-04-13  10:35:30 Centos7 yum 安装 Python3 2020-04-13  10:35:19