The tutorial for compiling and installing Tomcat on CentOS 8 Stream system is as follows:
First, make sure your CentOS 8 Stream system has the Java Development Kit (JDK) installed. You can install OpenJDK using the following command:
sudo dnf install java-1.8.0-openjdk-devel
Download the Tomcat compressed package. You can visit the official website of Apache Tomcat (
) or use the following command to download:
wget
Decompress the Tomcat compressed package:
tar -zxvf apache-tomcat-9.0.52.tar.gz
Move the decompressed Tomcat folder to the appropriate location. Here we move it to the /opt
directory:
sudo mv apache-tomcat-9.0.52 /opt/tomcat
Create a system user and group for Tomcat:
sudo groupadd tomcat sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
Configure Tomcat’s file permissions:
sudo chgrp -R tomcat /opt/tomcat sudo chmod -R g+r /opt/tomcat/conf sudo chmod g+x /opt/tomcat/conf sudo chown -R tomcat /opt/tomcat/webapps /opt/tomcat/work /opt/tomcat/temp /opt/tomcat/logs
Edit Tomcat startup script file:
sudo vi /opt/tomcat/bin/startup.sh
Add the following content at the beginning of the file:
#!/bin/bashCATALINA_HOME=/opt/tomcat
Save and close the file.
Set Tomcat to start automatically at boot:
sudo vi /etc/systemd/system/tomcat.service
Add the following:
[Unit]Description=Apache TomcatAfter=syslog.target network.target[Service]Type=forkingUser=tomcatGroup=tomcatEnvironment=CATALINA_PID=/opt/tomcat/temp/tomcat.pidEnvironment=CATALINA_HOME=/opt/tomcatEnvironment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom'ExecStart=/opt/tomcat/bin/startup.shExecStop=/opt/tomcat/bin/shutdown.sh[Install]WantedBy=multi-user.target
Save and close the file.
Start Tomcat service:
sudo systemctl start tomcat
Configure the firewall to allow Tomcat's HTTP and HTTPS traffic to pass:
sudo firewall-cmd --permanent --add-port=8080/tcpsudo firewall-cmd --permanent --add-port=8443/tcpsudo firewall-cmd --reload
Now,
You can verify whether Tomcat is successfully installed and running by visiting .
The above is the basic tutorial for compiling and installing Tomcat on CentOS 8 Stream system. Please note that the specific configuration and parameters may vary according to your needs, and you can adjust them according to your own situation. Also, make sure to back up important files and configurations before performing any operations.
The above is the detailed content of Tutorial on compiling and installing Tomcat on Centos8 stream system.. For more information, please follow other related articles on the PHP Chinese website!