This tutorial introduces how to install tomcat 8.5 on AWS Ubuntu instance 16.04.

Start your AWS instance, and connect to it using SSH.

For this step, please refer to the previous tutorial on how to use AWS.

Download Tomcat

You can find latest version of tomcat 8.5.x from You can copy the download URL and use the wget command on AWS to download it.

Then use wget on your AWS machine to download it:

wget latest_tomcat_download_url (it should look like this:

After you download the tar.gz, decompress it to a desired destination (for example, I use /home/ubuntu/tomcat)

mkdir /home/ubuntu/tomcat
tar xvf apache-tomcat-8.5.37.tar.gz -C /home/ubuntu/tomcat/ --strip-components=1

Now go to /home/ubuntu/tomcat/, and use ls, you show see the following contents:

Configure Tomcat Memory

By default, the maximum heap available for Tomcat may not be enough for large projects. Thus, we need to change the memory configuration by the following steps.

Go to /home/ubuntu/tomcat/bin/, and create a text file name, which contains the following lines:

env JAVA_OPTS="-Xmx512m -Xms128m"

Xmx means the maximum heap memory available for Tomcat, and Xms means the initial memory available after each garbage collection. You may vary them based on your machine capacity.

Change Access Setting of host-manager and manager

host-manager and manager are two useful default applications provided by Tomcat to manage the Tomcat server. However, by default they can be accessed by only the machine hosting tomcat, i.e., localhost.

To change this, you need to change /home/ubuntu/tomcat/webapps/host-manager/META-INF/context.xml and /home/ubuntu/tomcat/webapps/manager/META-INF/context.xml by deleting the following lines:

<Valve className="org.apache.catalina.valves.RemoteAddrValve" 

      allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />

Create a Tomcat User

Now, create a tomcat user so that you can manage the tomcat server remotely.

Edit /home/ubuntu/tomcat/conf/tomcat-users.xml, and add the following line:

<user username="tomcat" password="123456" roles="manager-gui,admin-gui"/>

By doing so, you've created a user named "tomcat", and its password is "123456". You've also granted two roles "manager-gui" and "admin-gui" to it.

Start Tomcat

Now you are ready to start tomcat by executing the following command:


If you see this, then it means your tomcat has started properly.

Open port for AWS

If you do the above steps on your local machine, then you should be able to access http://localhost:8080 from your browser to access tomcat.

However, on AWS, the port 8080 is not opened to public by default. Thus, you need to open it as follows.

Go to your AWS console, and click the item under "Security Groups" for your instance.

Click "Edit" to add more inbound rules:

Access Tomcat

Now you should be able to access your tomcat server using http://[YOUR-AWS-PUBLIC-IP]:8080, and you should be able to see the following page:

If you want to access manager or host-manager, just click the button on the right, and type the username/password you've set in the tomcat-users.xml file.

Last modified 18 months ago Last modified on Jan 10, 2019 2:29:43 PM

Attachments (8)

Download all attachments as: .zip