Open In App

How to install and configure Apache Tomcat 10 on Godaddy Server?

Last Updated : 07 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, 99% uptime, and much more. It’s a cheaper alternative to some other popular cloud-based services such as AWS, GPC, and Azure. Apache Tomcat is a cross-platform HTTP web server that runs Java code in a “pure Java” environment. It is an open-source implementation of Jakarta Servlet and Jakarta Expression Language. Since 1999, The Apache Software Foundation has been developing and releasing this product. This article will discuss how to install the latest version of Apache Tomcat on GoDaddy VPS (Ubuntu).

Installing Tomcat on Godaddy Server

Step 1: Open your terminal and ssh into the Godaddy server.

$ ssh [username]@[ip]

 

Step 2: Update and upgrade the server by running.

$ sudo apt update -y
$ sudo apt upgrade -y

 

Step 3: Create a new directory for the installation of tomcat.

 $ sudo mkdir /opt/tomcat/

 

Step 4: Visit https://tomcat.apache.org/download-10.cgi and copy the file path to the latest tarball package.

 

Step 5: Download the tarball by using wget tool.

$ wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.0.23/bin/apache-tomcat-10.0.23.tar.gz

 

Step 6: Move the extracted files to the tomcat directory.

$ sudo mv apache-tomcat-10.0.23/* /opt/tomcat/

 

Step 7: Modify the ownership and permissions for the tomcat directory.

$ sudo chown -R www-data:www-data /opt/tomcat/

$ sudo chmod -R 755 /opt/tomcat/

 

Step 8: Add manager and admin roles by updating the tomcat-users.xml file.

$ sudo nano /opt/tomcat/conf/tomcat-users.xml

tomcat-users.xml:

XML




<role rolename="manager-gui" />
<user username="manager" password="manager_password" roles="manager-gui" />
  
<role rolename="admin-gui" />
<user username="admin" password="admin_password" roles="manager-gui,admin-gui" />


 

Step 9: Edit the context.xml file to enable remote access to Apache Tomcat. Open the context.xml file with nano/vim and comment out the following section.

$ sudo nano /opt/tomcat/webapps/host-manager/META-INF/context.xml

context.xml:

XML




<Valve className="org.apache.catalina.valves.RemoteAddrValve"
       allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />


In the end, your file should look like this.

 

Step 10:  Now create a new systemd unit file to store the tomcat service. Make sure to configure the JAVA_HOME path variable correctly, if you use a more recent JDK version.

$ sudo nano /etc/systemd/system/tomcat.service

 

Step 11: Copy and paste the following.

[Unit]
Description=Tomcat
After=network.target

[Service]
Type=forking

User=root
Group=root

Environment=”JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64″
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

Step 12: Reload the systemd daemon so it can register the newly created service.

$ sudo systemctl daemon-reload

 

Step 13:  Now, run tomcat by using systemctl command.

$ sudo systemctl start tomcat
$ sudo systemctl status tomcat

 

Step 14: Once again, use the systemctl command to enable the tomcat service on the server. Now, tomcat will restart whenever the server boots up.

$ sudo systemctl enable tomcat

 

Step 15: Use ufw to open port 8080 for HTTP traffic.

$ sudo ufw allow 8080

 

Step 16: In your browser, navigate to http://server_ip:8080 to view the Tomcat welcome page.

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads