Create tomcat user and group
We need to add user dedicated to running tomcat service.
# groupadd --system tomcat
# useradd -d /usr/share/tomcat -r -s /bin/false -g tomcat tomcat
Install Tomcat 9 on Linux RHEL / CentOS 8
Check the latest release version of Tomcat 9. Save the version number to VER variable and proceed to download.
# dnf -y install wget
# export VER="9.0.XX"
# wget https://archive.apache.org/dist/tomcat/tomcat-9/v${VER}/bin/apache-tomcat-${VER}.tar.gz
Extract downloaded file with tar.
# tar xvf apache-tomcat-${VER}.tar.gz -C /usr/share/
# ln -s /usr/share/apache-tomcat-$VER/ /usr/share/tomcat
If you download a newer version of Tomcat, just update the symbolic link to the new version folder.
Set proper directory permissions.
# chown -R tomcat:tomcat /usr/share/tomcat
# chown -R tomcat:tomcat /usr/share/apache-tomcat-$VER/
Configure Tomcat 9 Systemd service
Create a new systemd service to Tomcat.
# vim /etc/systemd/system/tomcat.service
With 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=/usr/share/tomcat
Environment=CATALINA_BASE=/usr/share/tomcat
Environment=CATALINA_PID=/usr/share/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M'
ExecStart=/usr/share/tomcat/bin/catalina.sh start
ExecStop=/usr/share/tomcat/bin/catalina.sh stop
[Install]
WantedBy=multi-user.target
Start and enable service.
# sudo systemctl daemon-reload
# sudo systemctl enable tomcat
# sudo systemctl start tomcat
Check service status with the following command:
# systemctl status tomcat
Configure Firewall
# sudo firewall-cmd --permanent --add-port=8080/tcp
# sudo firewall-cmd --reload
Access Tomcat Web interface
Open browser and type http://ip-or-hostname:8080
No comments:
Post a Comment