Tutorial on compiling and installing Tomcat on Centos8 stream system.

PHPz
Release: 2024-02-19 21:27:02
forward
991 people have browsed it

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

    ) or use the following command to download:

    wget 
    Copy after login
  3. Decompress the Tomcat compressed package:

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

    sudo groupadd tomcat
    sudo useradd -M -s /bin/nologin -g tomcat -d /opt/tomcat tomcat
    Copy after login
  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
    Copy after login
  7. Edit Tomcat startup script file:

    sudo vi /opt/tomcat/bin/startup.sh
    Copy after login

    Add the following content at the beginning of the file:

    #!/bin/bashCATALINA_HOME=/opt/tomcat
    Copy after login

    Save and close the file.

  8. Set Tomcat to start automatically at boot:

    sudo vi /etc/systemd/system/tomcat.service
    Copy after login

    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
    Copy after login

    Save and close the file.

  9. Start Tomcat service:

    sudo systemctl start tomcat
    Copy after login
  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
    Copy after login

    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!

Related labels:
source:mryunwei.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!