和之前的Java版本不太一样,12版本不用配置JRE环境。
解压缩文件夹
root账户执行
tar -xzvf /home/software/jdk-12.0.2_linux-x64_bin.tar.gz
创建java文件夹
root账户执行
cd /usr
mkdir java
移动Java文件到创建的文件夹下
root账户执行
mv /home/software/jdk-12.0.2 /usr/java
配置环境变量
打开/etc/profile文件:vi /etc/profile
编辑文件,在最后添加:
export JAVA_HOME=/usr/java/jdk-12.0.2
export PATH=$PATH:$JAVA_HOME/bin
保存退出后,执行source /etc/profile使修改的环境变量生效
source /etc/profile
解压缩
tar -xzvf /home/software/apache-tomcat-9.0.74.tar.gz
移动到指定文件夹
mv /home/software/apache-tomcat-9.0.74 /home/arcgis/tomcat
创建自签名证书
cd /usr/java/jdk-12.0.2/bin
./keytool -genkey -alias tomcat -keyalg RSA -keystore /home/arcgis/tomcat/tomcat.keystore -validity 36500
设置密码,其他信息都输入机器全域名即可。
修改tomcat/conf/server.xml文件 ,修改端口为80,443
vi ./server.xml
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/home/arcgis/tomcat/tomcat.keystore" keystorePass="123456"/>
保存并退出
设置Tomcat开机自启动
进入 cd /home/arcgis/tomcat/bin/ 文件夹下,增加 setenv.sh文件,catalina.sh启动的时候会调用,同时配置java内存参数
#tomcat pid
export CATALINA_HOME=/home/arcgis/tomcat
export CATALINA_BASE=/home/arcgis/tomcat
#add tomcat pid
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#add Java opts
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
增加tomcat.service
vi /etc/systemd/system/tomcat.service
在文件中写入以下内容
[Unit]
Description=Tomcat
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/java/jdk-12.0.2"
PIDFile=/home/arcgis/tomcat/tomcat.pid
ExecStart=/home/arcgis/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
保存并退出
使用tomcat.service
相关命令
systemctl enable tomcat.service
systemctl start tomcat.service
systemctl status tomcat.service
systemctl stop tomcat.service
systemctl restart tomcat.service