It's been a long time since the last toss ...
Do not say this, just have free, the two-day toss of the Tomcat 8 service configuration organized out to collect.
1. JDK Installation
1) Check whether the server is pre-installed OPENJDK, if any, delete, here because my system is not so much to repeat.
2) Download the JDK installation package to Oracle's website, where I use jdk1.8.0_73, download jdk-8u73-linux-x64.rpm and upload to the server.
3) Execute the command in the installation package directory
RPM-IVH jdk-8u73-linux-x64.rpm
4) Run the command to see if the installation was successful
Java-version
Display Java version information, installation successful
Java Version "1.8.0_73"
Java (TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot (TM) 64-bit Server VM (build 25.73-b02, Mixed mode)
2. TOMCAT8 Configuration
1) Download Tomcat 8 and upload it to the server, where I downloaded the apache-tomcat-8.0.32.tar.gz version
2) Configure individual user tomcat to run the TOMCAT8 service, where Tomcat is configured with no login privileges for the account
-s/sbin/nologin-l Tomcat
3) Unzip Tomcat 8 and copy it to the Tomcat user directory
tar -zxv-f apache-tomcat-8.0. . Tar rm -rf apache-tomcat-8.0. . Tar mv apache-tomcat-8.0. + Tomcat MV tomcat//home/tomcat/
4) Grant directory permissions to Tomcat users
chown -R tomcat:tomcat/home/tomcat/tomcat
5) Add the boot configuration setenv.sh file under the bin directory of Tomcat 8
cd/home/tomcat/tomcat/binvi setenv. SH
setenv.sh file information about the following
#add tomcat Pidcatalina_pid= "/var/run/tomcat.pid"#add java_homejava_home=/usr/java/default# Add java_optsjava_opts= "-server-xms256m-xmx512m-xx:maxnewsize=256m"
6) Compile and install jsvc,jsvc is the daemon mode used to start the Tomcat 8 program, compiled in C language, you can open the 80 port under the ordinary user
cd/home/tomcat/tomcat/bintar -zxvf commons-daemon-native. Tar . GZ CD Commons-daemon-1.0. -native-src/. /configure--with-java=/usr/java/defaultmakecp jsvc. /..
7) Configure Tomcat 8 for the SYSTEMCTL service and create the file under/usr/lib/systemd/system tomcat.service
cd/usr/lib/systemd/systemVI tomcat.service
The contents of Tomcat.service are as follows
[Unit]Description=Tomcatafter=syslog.target network.target remote-fs.target nss-lookup.target[Service]Type=Forkingpidfile=/var/run/tomcat.pidexecstart=/home/tomcat/tomcat/bin/daemon.sh startexecreload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s QUIT $MAINPIDPrivateTmp=true[Install]Wantedby=multi-user.target
At this point, all configurations are basically complete
Set the command to start the boot
Systemctl Enable Tomcat
Start the service
Systemctl Start Tomcat
Restart Service
Systemctl Restart Tomcat
Stop Service
Systemctl Stop Tomcat
Configuration of the Tomcat 8 service launched in CentOS 7 via daemon mode