Original: Https://www.vultr.com/docs/how-to-install-apache-tomcat-8-on-centos-7
Apache Tomcat is an open source Web server specifically designed for Java and is widely used.
The following is a tutorial on installing Tomcat 8 in CENTOS7: system Requirements
1.centos7
2. Login non-root SSH account Step1 upgrade CentOS system
sudo yum install epel-release
sudo yum update-y && sudo reboot
Step2 Install Java
sudo yum install java-1.8.0-openjdk.x86_64
After the installation is complete, running java-version will output the following:
OPENJDK version "1.8.0_91"
openjdk Runtime Environment (build 1.8.0_91-b14) openjdk 64-bit
Server VM (Build 25.91 -B14, Mixed mode)
STEP3 New Tomcat dedicated user
sudo groupadd tomcat
mkdir/opt/tomcat sudo
useradd-s/bin/nologin-g tomcat-d/opt/tomcat Tomcat
Note that the user directory is/opt/tomcat Step4 download and install the latest version of Tomcat
CD ~
wget http://www-us.apache.org/dist/tomcat/tomcat-8/v8.0.33/bin/apache-tomcat-8.0.33.tar.gz
sudo tar- ZXVF apache-tomcat-8.0.33.tar.gz-c/opt/tomcat--strip-components=1
STEP5 permission Settings
Cd/opt/tomcat
sudo chmod-r tomcat.
sudo chgrp-r tomcat conf
chmod g+rwx conf
sudo chmod g+r conf/*
sudo chown-r tomcat Logs/temp/webapps /work/
Step6 Create systemd unit files for Tomcat
sudo vi/etc/systemd/system/tomcat.service
The contents are as follows:
[Unit]
Description=apache Tomcat Web Application Container
after=syslog.target network.target
[Service]
type= Forking
Environment=java_home=/usr/lib/jvm/jre
environment=catalina_pid=/opt/tomcat/temp/tomcat.pid
Environment=catalina_home=/opt/tomcat
Environment=catalina_base=/opt/tomcat
environment= ' catalina_opts=-xms512m-xmx1024m-server-xx:+ USEPARALLELGC '
environment= ' java_opts=-djava.awt.headless=true-djava.security.egd=file:/dev/./urandom '
execstart=/opt/tomcat/bin/startup.sh
Execstop=/bin/kill-15 $MAINPID
user=tomcat
group=tomcat
[Install]
wantedby= Multi-user.target
STEP7 Installation haveged
sudo yum install haveged
sudo systemctl start haveged.service
sudo systemctl enable Haveged.service
STEP8 start Tomcat and turn on the firewall
sudo systemctl start tomcat.service
sudo systemctl enable Tomcat.service
sudo firewall-cmd--zone=public-- Permanent--add-port=8080/tcp
sudo firewall-cmd--reload
Access http://[your-host-ip]:8080 Preview is OK. STEP9 Configure the Tomcat management interface
sudo vi/opt/tomcat/conf/tomcat-users.xml
Add an admin account to <tomcat-users ...>...</tomcat-users>:
<user username= "YourUserName" password= "YourPassword" roles= "Manager-gui,admin-gui"/>
And then restart Tomcat.
sudo systemctl restart Tomcat.service