Knowledgebase

Install Apache Tomcat on Ubuntu 20.04 Print

  • 0

Introduction

Apache Tomcat is an open-source, lightweight web server for running Java-based websites and applications. It's an implementation of the Jakarta EE platform which is the modification of the Java EE platform to accommodate distributed computing and web services. This article explains how to install Apache Tomcat on Ubuntu 20.04 server.

Prerequisites

1. Install Java

Update system packages.

$ sudo apt update

Install Java runtime environment.

$ sudo apt install default-jdk -y

Verify Java installation.

$ java -version

2. Install Tomcat

Download the latest version of Apache Tomcat. To find the latest Tomcat version, visit the official download page.

$ wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.8/bin/apache-tomcat-10.0.8.tar.gz

Extract the downloaded archive.

$ sudo tar xzvf apache-tomcat-10.0.8.tar.gz

Create an installation directory /opt/tomcat/.

$ sudo mkdir /opt/tomcat/

Move the extracted files to the installation directory.

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

Change ownership of the installation directory.

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

Change access permissions for the installation directory.

$ sudo chmod -R 755 /opt/tomcat/

Edit conf/tomcat-users.xml file to configure an administrator and manager account for Apache Tomcat.

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

Add the code below within the <tomcat-users> tag. Change the password for administrator and manager access by changing the value StrongPassword below with a high secure password.

<!-- user manager can access only manager section -->
<role rolename="manager-gui" />
<user username="manager" password="StrongPassword" roles="manager-gui" />

<!-- user admin can access manager and admin section both -->
<role rolename="admin-gui" />
<user username="admin" password="StrongPassword" roles="manager-gui,admin-gui" />

Enable remote access to Apache Tomcat by editing manager and host-manager configuration files. Edit manager application context.xml file:

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

Comment out the IP addresses section as shown below. Then, save and close the file.

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

Edit host manager application context.xml file:

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

Comment out the IP addresses section as shown below. Then, save and close the file.

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

Create a systemd unit file for Apache Tomcat.

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

Add the code below to the file. Then, save and close the file.

[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

Reload the systemd daemon service to apply changes.

$ sudo systemctl daemon-reload

Start Apache Tomcat service.

$ sudo systemctl start tomcat

Enable the service to start up on system boot.

$ sudo systemctl enable tomcat

Check the status of the service.

$ sudo systemctl status tomcat

3. Access Apache Tomcat Web Interface

Go to your browser address bar to access the web interface and type in http://ServerIPaddress:8080 for SuiteCRM to access the web install wizard. For example:

http://192.0.2.10:8080

Conclusion

You have installed Apache Tomcat on your server. You can now access the main dashboard begin managing your Java applications.

More Information

For more information about Apache Tomcat, please see the official documentation.

Introduction Apache Tomcat is an open-source, lightweight web server for running Java-based websites and applications. It's an implementation of the Jakarta EE platform which is the modification of the Java EE platform to accommodate distributed computing and web services. This article explains how to install Apache Tomcat on Ubuntu 20.04 server. Prerequisites Deploy a fully updated Rcs Ubuntu 20.04 Server. Create a non-root user with sudo access. 1. Install Java Update system packages. $ sudo apt update Install Java runtime environment. $ sudo apt install default-jdk -y Verify Java installation. $ java -version 2. Install Tomcat Download the latest version of Apache Tomcat. To find the latest Tomcat version, visit the official download page. $ wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.0.8/bin/apache-tomcat-10.0.8.tar.gz Extract the downloaded archive. $ sudo tar xzvf apache-tomcat-10.0.8.tar.gz Create an installation directory /opt/tomcat/. $ sudo mkdir /opt/tomcat/ Move the extracted files to the installation directory. $ sudo mv apache-tomcat-10.0.8/* /opt/tomcat/ Change ownership of the installation directory. $ sudo chown -R www-data:www-data /opt/tomcat/ Change access permissions for the installation directory. $ sudo chmod -R 755 /opt/tomcat/ Edit conf/tomcat-users.xml file to configure an administrator and manager account for Apache Tomcat. $ sudo nano /opt/tomcat/conf/tomcat-users.xml Add the code below within the tag. Change the password for administrator and manager access by changing the value StrongPassword below with a high secure password. Enable remote access to Apache Tomcat by editing manager and host-manager configuration files. Edit manager application context.xml file: $ sudo nano /opt/tomcat/webapps/manager/META-INF/context.xml Comment out the IP addresses section as shown below. Then, save and close the file. Edit host manager application context.xml file: $ sudo nano /opt/tomcat/webapps/host-manager/META-INF/context.xml Comment out the IP addresses section as shown below. Then, save and close the file. Create a systemd unit file for Apache Tomcat. $ sudo nano /etc/systemd/system/tomcat.service Add the code below to the file. Then, save and close the file. [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 Reload the systemd daemon service to apply changes. $ sudo systemctl daemon-reload Start Apache Tomcat service. $ sudo systemctl start tomcat Enable the service to start up on system boot. $ sudo systemctl enable tomcat Check the status of the service. $ sudo systemctl status tomcat 3. Access Apache Tomcat Web Interface Go to your browser address bar to access the web interface and type in http://ServerIPaddress:8080 for SuiteCRM to access the web install wizard. For example: http://192.0.2.10:8080 Conclusion You have installed Apache Tomcat on your server. You can now access the main dashboard begin managing your Java applications. More Information For more information about Apache Tomcat, please see the official documentation.

Was this answer helpful?
Back

Powered by WHMCompleteSolution