Created
November 30, 2020 10:53
-
-
Save kngvamxx/d3d7be0715e5dee8d5b306dac641726a to your computer and use it in GitHub Desktop.
how to install apache tomcat on linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1: Install OpenJDK | |
Simply run the commands below to install OpenJDK: | |
sudo apt update | |
sudo apt install default-jdk | |
Step 2: Create Tomcat Service Account | |
sudo groupadd tomcat | |
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat | |
Step 3: Download Tomcat Packages | |
cd /tmp | |
wget ftp://apache.cs.utah.edu/apache.org/tomcat/tomcat-8/v9.0.35/bin/apache-tomcat-9.0.35.tar.gz | |
sudo mkdir /opt/tomcat | |
##Next, give the tomcat user control of the entire directory and make all the scripts in the bin location executable… | |
sudo chown -R tomcat: /opt/tomcat | |
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh' | |
Step 4: Configure Tomcat Service | |
sudo nano /opt/tomcat/conf/tomcat-users.xml | |
###Then create an account with password for the user and save by copying and pasting the lines below into the file.. | |
<role rolename="manager-gui"/> | |
<role rolename="admin-gui"/> | |
####Next, run the commands below to create a server account for Tomcat | |
sudo nano /etc/systemd/system/tomcat.service | |
###then copy and paste the lines below into the file and save | |
[Unit] | |
Description=Tomcat servlet container | |
After=network.target | |
[Service] | |
Type=forking | |
User=tomcat | |
Group=tomcat | |
Environment="JAVA_HOME=/usr/lib/jvm/default-java" | |
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom" | |
Environment="CATALINA_BASE=/opt/tomcat" | |
Environment="CATALINA_HOME=/opt/tomcat" | |
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid" | |
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC" | |
ExecStart=/opt/tomcat/bin/startup.sh | |
ExecStop=/opt/tomcat/bin/shutdown.sh | |
[Install] | |
WantedBy=multi-user.target | |
####After that, run the commands below to reload systemd profiles and enable tomcat service… | |
sudo systemctl daemon-reload | |
sudo systemctl start tomcat.service | |
sudo systemctl enable tomcat.service | |
sudo systemctl status tomcat.service | |
###Now, open your browser and browse to the local server IP or hostname | |
http://localhost:8080 |
Author
kngvamxx
commented
Nov 30, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment