How To Install Apache Tomcat 8 on CentOS 7
How To Install Apache Tomcat 8 on CentOS 7
Step 1: Update the System
Before installing Apache Tomcat 8 on CentOS 7, it's important to ensure that the system is up-to-date. Run the following command in the terminal:
sudo yum update
Step 2: Install Java Development Kit (JDK)
Apache Tomcat 8 requires a Java Development Kit (JDK) to be installed on the system. Run the following command to install JDK:
sudo yum install java-1.8.0-openjdk-devel
Step 3: Download and Extract Apache Tomcat 8
Download the latest version of Apache Tomcat 8 from the official website. Once downloaded, extract the contents of the archive to a directory of your choice:
cd /opt
sudo wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.71/bin/apache-tomcat-8.5.71.tar.gz
sudo tar -zxvf apache-tomcat-8.5.71.tar.gz
Step 4: Create a Systemd Service File
Create a systemd service file to manage the Apache Tomcat 8 service:
sudo nano /etc/systemd/system/tomcat.service
Copy and paste the following contents into the file:
[Unit]
Description=Apache Tomcat 8 Servlet Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
Environment=CATALINA_PID=/opt/apache-tomcat-8.5.71/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/apache-tomcat-8.5.71
Environment=CATALINA_BASE=/opt/apache-tomcat-8.5.71
ExecStart=/opt/apache-tomcat-8.5.71/bin/startup.sh
ExecStop=/opt/apache-tomcat-8.5.71/bin/shutdown.sh
User=tomcat
Group=tomcat
UMask=0007
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
Save and close the file.
Step 5: Create a Tomcat User
Create a new user and group to run the Apache Tomcat 8 service:
sudo useradd -r -m -U -d /opt/apache-tomcat-8.5.71 -s /bin/false tomcat
Step 6: Enable and Start the Service
Enable the service to start on boot:
sudo systemctl enable tomcat
Комментарии
Отправить комментарий