Home  >  Article  >  Computer Tutorials  >  Tutorial on compiling and installing Tomcat on Centos8 stream system.

Tutorial on compiling and installing Tomcat on Centos8 stream system.

PHPz
PHPzforward
2024-02-19 21:27:021009browse

Centos8 stream系统编译安装Tomcat教程。

The tutorial for compiling and installing Tomcat on CentOS 8 Stream system is as follows:

  1. 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
  2. Download the Tomcat compressed package. You can visit the official website of Apache Tomcat (

    ) or use the following command to download:

    wget 
  3. Decompress the Tomcat compressed package:

    tar -zxvf apache-tomcat-9.0.52.tar.gz
  4. 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
  5. Create a system user and group for Tomcat:

    sudo groupadd tomcat
    sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
  6. 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
  7. 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.

  8. 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.

  9. Start Tomcat service:

    sudo systemctl start tomcat
  10. 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!

Statement:
This article is reproduced at:mryunwei.com. If there is any infringement, please contact admin@php.cn delete