How to Install Latest Apache Tomcat 8.5.14 in Linux

Step 3: Changing Apache Tomcat Port

8. Do remember that 8080 is the default port tomcat usages. To change tomcat port from 8080 to any other unused port (say 137), you may do as:

First shutdown tomcat server simply by typing the below command from anywhere in the shell.

# tomcatdown

Next, open ‘/opt/tomcat/apache-tomcat-8.5.14/conf/server.xml‘ file in your favorite editor (mine is nano) to edit. Change port 8080 to 137, save and exit.

# nano /opt/tomcat/apache-tomcat-8.5.14/conf/server.xml
Sample Output
 <Connector port="137" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

After changing port to 137, restart tomcat service again and point your browser to http://127.0.0.1:137.

# tomcatup

Similarly, you can use any port of your choice. Make sure the port you are using don’t conflict with any other application/resource.

Step 4: Configuring Apache Tomcat 8

9. By default the Tomcat page is accessed by you only due its security implementation so that unauthorized users don’t have access to it.

To access admin and other sections like Server Status, Manager App and Host Manager. You need to add user accounts for admins and managers.

To add a Tomcat user edit file ‘/opt/tomcat/apache-tomcat-8.5.14/conf/tomcat-users.xml‘, in your favorite editor.

# nano /opt/tomcat/apache-tomcat-8.5.14/conf/tomcat-users.xml

10. Add the following lines just before ‘</tomcat-users>‘.

<role rolename="admin-gui"/>
<user username="admin" password="tecmint" roles="admin-gui"/>

<role rolename="manager-gui"/>
<user username="avi" password="tecmint123" roles="manager-gui"/>
Add Tomcat Users
Add Tomcat Users

Again, you need to restart Tomcat to take new changes into effect.

# tomcatdown
# tomcatup

11. After restarting Tomcat, make sure to access the admin other sections like Server Status, etc at http://127.0.0.1:137.

It you will be asked to Enter User_name and Password, you just created above, after login you will see something like the below interface.

Apache Tomcat User Login
Apache Tomcat User Login
Apache Tomcat Server Status
Apache Tomcat Server Status

Your all setting and basic configuration of Tomcat has finished now. Now we will see a simple example (beyond the scope of this article), a very basic program (JSP Program) to run in Tomcat. It would be dumb if we do not show it.

12. Create a file called tecmint.jsp under ‘/opt/tomcat/apache-tomcat-8.5.14/webapps/ROOT‘ directory.

# touch /opt/tomcat/apache-tomcat-8.5.14/webapps/ROOT/tecmint.jsp

13. Now put the below contents in the new file (tecmint.jsp), save and exit. You may edit it, if you know what you are doing.

<html>
<head>
<title>Tecmint post:TomcatServer</title>
</head>
<body>

<START OF JAVA CODES>
<%
    out.println("Hello World! I am running my first JSP Application");
    out.println("<BR>Tecmint is an Awesome online Linux Resource.");
%>
<END OF JAVA CODES>

</body>
</html>
Create JSP Program
Create JSP Program

Most of the things in the above codes are self explaining. We have put simple Java code to print two lines of output and embed it in between HTML codes, which can be accessed at http://127.0.0.1:137/tecmint.jsp.

JSP Page
JSP Page

Congratulations! You have successfully run your Tomcat Application. That’s all for now from me. We are just exploring if our readers are interested in a detailed JAVA Tutorial on Tecmint. Please let us know your valuable thoughts in the comments below. Like and share us and help us get spread.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

14 thoughts on “How to Install Latest Apache Tomcat 8.5.14 in Linux”

  1. After installing Java and apache tomcat, i am able to start the apache service, but while i am trying to hit the apache URL i am getting 500 error, can please help.

    Reply
    • @Shanmuga,

      Are you sure your apache tomcat started up correctly? also have you opened port 8080 on firewall? If yes, do check the apache logs for any errors.

      Reply
    • @Krishna,

      The article is updated and included installation instructions for latest Apache Tomcat version..

      Reply
  2. Hi,

    Thanks for your helpful tutorials. Just wanted to ask if it is necessary to configure a java_home environment after installing the java packages. I am confused because I came across this tutorial that configured a java environment and edited the file before installing Tomcat. Why is this necessary? I’ll paste the website’s URL below. Thanks.

    Reply
  3. Nice article Avishek Kumar. I am looking forward for Java Tutorials on TecMint. I am regularly reading article on tecmint but first time I am posting comment here. Thank you for your efforts to give such nice tutorials.

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.