In CentOS 7, the Tomcat 8 service is started in daemon mode.

Source: Internet
Author: User

In CentOS 7, the Tomcat 8 service is started in daemon mode.

If you have no time in the past few days, set the configuration in CentOS 7 to start the Tomcat 8 service in daemon mode.

1. JDK Installation

1) check whether the server is pre-installed with openJdk. If yes, delete it. here we will not repeat it here because it is not in my system.

2) to the Oracle official website to download the JDK installation package, here I use jdk1.8.0 _ 73, the official website to download the jdk-8u73-linux-x64.rpm and upload to the server.

3) run the command in the installation package directory.

Rpm-ivh jdk-8u73-linux-x64.rpm

4) run the command to check whether the installation is successful.

Java-version

The java version is displayed. The installation is 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 to the server, here I download the apache-tomcat-8.0.32.tar.gz version

2) configure a separate user tomcat to run the tomcat 8 service. Here, tomcat is configured as an account with no logon permission.

Groupadd tomcat
Useradd-s/sbin/nologin-g tomcat
Usermod-L tomcat

3) decompress Tomcat 8 and copy it to the tomcat user directory.

Tar-zxv-f apache-tomcat-8.0.32.tar.gz
Rm-rf apache-tomcat-8.0.32.tar.gz
Mv apache-tomcat-8.0.32 tomcat
Mv tomcat // home/tomcat/

4) grant directory permissions to tomcat users

Chown-R tomcat: tomcat/home/tomcat

5) Add the startup configuration setenv. sh file in the bin directory of Tomcat 8.

Cd/home/tomcat/bin
Vi setenv. sh

The content of the setenv. sh file is as follows:

# Add tomcat pid
CATALINA_PID = "/var/run/tomcat. pid"
# Add JAVA_HOME
JAVA_HOME =/usr/java/default
# Add JAVA_OPTS
JAVA_OPTS = "-server-Xms256M-Xmx512M-XX: MaxNewSize = 256 m"

6) Compile and install jsvc. jsvc is the daemon mode used to start the Tomcat 8 program. Through C language compilation, port 80 can be opened under normal users.

Cd/home/tomcat/bin
Tar-zxvf commons-daemon-native.tar.gz
Cd commons-daemon-1.0.15-native-src/
./Configure -- with-java =/usr/java/default
Make
Cp jsvc ../..

7) Configure Tomcat 8 as the systemctl service and create the tomcat. service file under/usr/lib/systemd/system.

Cd/usr/lib/systemd/system
Vi tomcat. service

The content of tomcat. service is as follows:

[Unit]
Description = Tomcat
After1_syslog.tar get network.tar get remote-fs.target nss-lookup.target

[Service]
Type = forking
PIDFile =/var/run/tomcat. pid
ExecStart =/home/tomcat/bin/daemon. sh start
ExecReload =/bin/kill-s HUP $ MAINPID
ExecStop =/bin/kill-s QUIT $ MAINPID

PrivateTmp = true

[Install]
Wantedbypolicmulti-user.tar get

Now, all configurations are complete.

Set the startup command

Systemctl enable tomcat

Start the service

Systemctl start tomcat

Restart service

Systemctl restart tomcat

Stop Service

Systemctl stop tomcat

For more Tomcat tutorials, see the following:

Install and configure the Tomcat environment in CentOS 6.6

Install JDK + Tomcat in RedHat Linux 5.5 and deploy Java Projects

Tomcat authoritative guide (second edition) (Chinese/English hd pdf + bookmarks)

Tomcat Security Configuration and Performance Optimization

How to Use Xshell to view Tomcat real-time logs with Chinese garbled characters in Linux

Install JDK and Tomcat in CentOS 64-bit and set the Tomcat Startup Procedure

Install Tomcat in CentOS 6.5

Tomcat details: click here
Tomcat: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.