Purpose of this article
Purely recorded for later investigation.
1. Install JAVA JDK
Jdk installed slightly.
Configuring the JDK, open / etc / profile file, add the following code at the end:
JAVA_HOME=/usr/java/jdk1.8.0_211 JRE_HOME=/usr/java/jdk1.8.0_211/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
Then run the command, refresh configuration:
source /etc/profile
2. Install tomcat
Under usr / local / directory, add a new directory tomcat, then go to the directory, access tomcat:
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.20/bin/apache-tomcat-9.0.20.tar.gz
Extracting archive
zxvf apache-tomcat tar 9.0 . 20 .tar.gz
Then bin file in the installation directory folder, the new file: setenv.sh, which reads as follows:
# Create setenv.sh file in the bin directory of tomcat directory, # catalina.sh because at the time of execution of calls at the same level setenv.sh path to set additional environmental variables. CATALINA_HOME Export = / usr / local / Tomcat / Apache-tomcat- 9.0 . 20 is Export CATALINA_BASE = / usr / local / Tomcat / Apache-tomcat- 9.0 . 20 is #add Tomcat PID CATALINA_PID = " $ CATALINA_BASE / TEMP / tomcat.pid " the opts the Java #add the JAVA_OPTS = " -server -XX: PermSize = 256M -XX: MaxPermSize = 1024M -Xms512m -Xmx1024M -XX: MaxNewSize = 256M "
In the / usr / lib / systemd / system directory, create a new file tomcat.service, which reads as follows:
# 在/usr/lib/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/jdk1.8.0_211/" PIDFile=/usr/local/tomcat/apache-tomcat-9.0.20/temp/tomcat.pid ExecStart=/usr/local/tomcat/apache-tomcat-9.0.20/bin/startup.sh ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
chmod 754 tomcat.service
If you do not restart, direct start tomcat.service, it will error:
After rebooting run the command: systemctl start tomcat.service can start tomcat normal, and you can use the command to view the status:
systemctl status tomcat.service
After the confirmation, you can also use the command to set the tomcat systemctl enable tomcat.service random start.
Thereafter, no log mode: . -Jar ***** Java JAR or log mode using nohup java -jar ************ jar> **********. **. log 2> & 1 & to start the java program, and see the results.
End of this article.
References: https://www.cnblogs.com/hglibin/p/9562867.html