1. Install Java
Read tutorial “Linux – Installing Java 8 on CentOS 8”
2. Create Tomcat User and Group
sudo groupadd –system tomcat
sudo useradd -d /opt/tomcat -r -s /bin/false -g tomcat tomcat
3. Install Tomcat
3.a. Download Tomcat
export VER="9.0.30"
wget https://archive.apache.org/dist/tomcat/tomcat-9/v${VER}/bin/apache-tomcat-${VER}.tar.gz
3.b. Extract downloaded file.
sudo tar xvf apache-tomcat-${VER}.tar.gz -C /tomcat/
3.c. Create symlink to extracted tomcat data
sudo ln -s /opt/apache-tomcat-$VER/ /opt/tomcat
3.d. Set proper permission
sudo chown -R tomcat:tomcat /opt/tomcat
sudo chown -R tomcat:tomcat /opt/apache-tomcat-$VER
4. Create Tomcat 9 Systemd Service
4.a. Create new system service to Tomcat
sudo vi /etc/systemd/system/tomcat.service
4.b. Add below configuration
[Unit]
Description=Tomcat Server
After=syslog.target network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment='JAVA_OPTS=-Djava.awt.headless=true'
Environment=CATALINA_HOME=/opt/tomcat
Environment=CATALINA_BASE=/opt/tomcat
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M'
ExecStart=/opt/tomcat/bin/catalina.sh start
ExecStop=/opt/tomcat/bin/catalina.sh stop
[Install]
WantedBy=multi-user.target
4.c. Start and enable service
sudo systemctl daemon-reload
sudo systemctl start tomcat
sudo systemctl enable tomcat
4.d. Check service status
systemctl status tomcat
5. Configure Firewall
Installing Tomcat 9 on CentOS 8
6. Configure Tomcat Authentication
Open tomcat-users.xml
sudo vi /opt/tomcat/conf/tomcat-users.xml
Add following configuration
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="password" fullName="Administrator" roles="admin-gui,manager-gui"/>
7. Configure Tomcat Proxy
8. Access Tomcat Web Interface