Ubuntu 16.04 method of installing Apache Tomcat

  • 2020-05-12 06:37:36
  • OfStack

Apache Tomcat is an open source software implementation of Java Servlet and Java Server Pages technologies. You can use OpenJDK tomcat to run your Java application.

Apache Tomcat installation

Install Tomcat from the Ubuntu software library:


apt-get install tomcat8

You may also need to install the tomcat8-docs, tomcat8-examples, and tomcat8-admin tools, which provide documentation, testing, and allow you to manage Tomcat for Web-based applications. You can install all three using the following command:


apt-get install tomcat8-docs tomcat8-examples tomcat8-admin

If you need to start, stop or restart Tomcat, you can use the following command:


systemctl start tomcat8
systemctl stop tomcat8
systemctl restart tomcat8

Test and use Tomcat

In your browser open http: / / example com: 8080 / to validate tomcat installation. Note that Tomcat is listening to network port 8080 and by default does not accept forced HTTPS connections. By default, Tomcat configuration files in the/var/lib/tomcat8 / conf directory.

To use tomcat8 - admin web application, please add the following line to the/var/lib/tomcat8 / conf/tomcat - users. xml file before the line to replace your own user name and password. If you are using the Tomcat administrator, add the "manager-gui" role for manager and the "admin-gui" role for the host-manager application.

If you do not deploy the Web application and only need to run the application from the command line, you should not enter these lines because doing so could expose your server to unauthorized login attempts.


/var/lib/tomcat8/conf/tomcat-users.xml : 
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="username" password="password" roles="manager-gui,admin-gui"/>

Restart to take effect configuration:


systemctl restart tomcat8

Related articles: