BogoToBogo
  • Home
  • About
  • Big Data
  • Machine Learning
  • AngularJS
  • Python
  • C++
  • go
  • DevOps
  • Kubernetes
  • Algorithms
  • More...
    • Qt 5
    • Linux
    • FFmpeg
    • Matlab
    • Django 1.8
    • Ruby On Rails
    • HTML5 & CSS

Apache Tomcat 7 Ubuntu 14.04 install on Amazon EC2 instance - 2020

Duke 512




Bookmark and Share





bogotobogo.com site search:





Apache Tomcat

The Apache Tomcat server is an open source, Java-based web server and servlet container. It was created to run servlet and JavaServer Pages (JSP) web applications. Though created under the Apache-Jakarta subproject, due to its popularity, it is now hosted as a separate Apache project, where it is supported and enhanced by a group of volunteers from the open source Java community.

Tomcat implements several Java EE specifications including Java Servlet, JavaServer Pages (JSP), Java EL, and WebSocket, and provides a "pure Java" HTTP web server environment for Java code to run in.

tomcat-chart.png



Apache Tomcat versions

Major versions on Apache Tomcat coincide with versions of the Java Servlet specification, or Java Servlet API, released. So, Tomcat 5.5X supports Servlet API 2.3, Tomcat 6.0X supports Servlet API 2.4, and the latest Tomcat 7.0 is a reference implementation of current Servlet.

The following table shows Tomcat versions and supported API and JDK versions:

Apache Tomcat Servlet API JSP API JDK
9.0 4.0 2.4 1.8+
8.0 3.1 2.3 1.7+
7.0 3.0 2.2 1.6+
6.0 2.5 2.1 1.5+
5.5 2.4 2.0 1.4




Architecture of Tomcat

"A Tomcat instance, or server, is the top-level component in Tomcat's container hierarchy. Only one Tomcat instance can live in a single Java Virtual Machine (JVM). This approach makes all other Java applications, running on the same physical machine as Tomcat server, safe in case Tomcat and/or its JVM crashes." - Apache Tomcat 7 by Aleksa Vukotic & James Goodwill



Note

In this article, we'll learn basic installation and configuration of Tomcat 7 on Ubuntu 14.04.

Please visit Spring Boot : Deploying War file to Tomcat 8's webapps
for more information about installing Tomcat 7 and Tomcat 8 as well as deploying a war file to Tomcat server.




Ubuntu EC2

Our ec2 account is: ec2-54-173-97-70.compute-1.amazonaws.com

$ chmod 600 ~/Downloads/Tomcat7.pem

ssh to ec2:

$ ssh -i ~/Downloads/Tomcat7.pem ubuntu@ec2-54-173-97-70.compute-1.amazonaws.com
...
ubuntu@ip-172-31-21-148:~$ 




Install Tomcat

Update our apt-get package lists:

$ sudo apt-get update

Install Tomcat:

$ sudo apt-get install tomcat7

This will install Tomcat, and it will also create the tomcat7 user with default settings. Tomcat is not completely set up yet, but we can access the default splash page with port 8080 in a browser.

But for EC2, the firewall blocks 8080, so we need to redirect the request from port 80 to port 8080. We'll do it using proxy setup via Apache:

ubuntu@ip-172-31-21-148:~$ sudo apt-get install apache2
ubuntu@ip-172-31-21-148:~$ sudo a2enmod proxy
ubuntu@ip-172-31-21-148:~$ sudo a2enmod proxy_http

Now we need to configure Apache to actually proxy the request from port 80 to port 8080.

ubuntu@ip-172-31-21-148:~$ vi /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
        ...

        ServerAdmin ec2-54-173-97-70.compute-1.amazonaws.com
        ProxyRequests Off
        <Proxy *>
            Order deny,allow
            Allow from all
        </Proxy>
        ProxyPreserveHost on
        ProxyPass / http://localhost:8080/
        DocumentRoot /var/www/html

        ...
</VirtualHost>
Tomcat_It_works.png



Installing Additional Packages

We will install the Tomcat online documentation, the web interface (manager webapp), and a few example webapps:

$ sudo apt-get install tomcat7-docs tomcat7-admin tomcat7-examples

The Java Development Kit (JDK) enables us to develop Java applications to run in our Tomcat server. Running the following command will install openjdk-7-jdk:

$ sudo apt-get install default-jdk

the Tomcat documentation suggests also installing Apache Ant, which is used to build Java applications, and a source control system, such as git. Let's install both of those with the following command:

$ sudo apt-get install ant git




Configure Tomcat Web Management Interface

In order to use the manager webapp installed in the previous section, we must add a login to our Tomcat server. We will do this by editing the tomcat-users.xml file:

$ sudo vi /etc/tomcat7/tomcat-users.xml

This file is filled with comments which describe how to configure the file. We may want to delete all the comments between the following two lines, or we may leave them if we want to reference the examples:

<tomcat-users>
</tomcat-users>

We will want to add a user who can access the manager-gui and admin-gui. We can do so by defining a user similar to the example below. Be sure to change the password and username if we want:

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

Save and quit the tomcat-users.xml file. To put our changes into effect, restart the Tomcat service:

$ sudo service tomcat7 restart




Web Application Manager

ip-address/manager/html/:

AuthenticationRequired.png

After login in to manager-gui, we get:


Manager_htmlA.png

The Web Application Manager is used to manage our Java applications. We can Start, Stop, Reload, Deploy, and Undeploy here. We can also run some diagnostics on our apps (i.e. find memory leaks). Lastly, information about our server is available at the very bottom of this page.





Virtual Host Manager

From the Virtual Host Manager page, we can add virtual hosts to serve our applications.

ip-address/host-manager/html:


HostManagerHtml.png



Note

Please visit Spring Boot : Deploying War file to Tomcat 8's webapps
for more information about installing Tomcat 7 and Tomcat 8 as well as deploying a war file to Tomcat server.









Ph.D. / Golden Gate Ave, San Francisco / Seoul National Univ / Carnegie Mellon / UC Berkeley / DevOps / Deep Learning / Visualization

YouTubeMy YouTube channel

Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







Java Tutorials



Java Tutorial Home

Basics - Compiling and Launching

Inner Classes

Constructor

Enums

Static & Finally

Default and Protected

Polymorphism

Exception Handling

Exception Handling II

String Class

Threads

Threads II - State Transition

Threads III - Synchronization

Object Class

File I/O

Serialization

ArrayList

Autoboxing

Java Graphics Interface I - Basics

Java Graphics Interface II - Labels, Text Fields, Layouts

Java Graphics Interface III - paintComponent

TCP Sockets Server/Client

Scala - Functional Java Programming

Apache CXF install

Tomcat 7 Ubuntu 14 Install on Amazon EC2 instance

What is Apache Maven?

Maven life cycle

Eclipse Maven 3 plugin on Ubuntu 14.04

Apache Maven 3 - Setting up and creating a project

Apache Maven 3 - Compile, build, and install a Maven project

Apache Maven 3 - Dependencies

Apache Maven 3 - Web Application

Apache Maven 3 - Plugins (compiler)

Apache Maven 3 - Plugins (Jetty)

Eclipse CDT / JNI (Java Native Interface) / MinGW



Spring Framework

Hello World App with Spring 4 & Maven 3 - Part I




Sponsor Open Source development activities and free contents for everyone.

Thank you.

- K Hong







Spring Boot



Spring Boot : Hello world with Mavan 3

Spring Boot : Hello world with Gradle 2

Spring Boot (Gradle 2) : Hello world with Authentication

Spring Boot : Deploying War file to Tomcat 8's webapps

How to Setup Apache as Reverse Proxy for Tomcat Server using mod proxy

Maven : mvn command cheat sheet

Spring-Boot REST API with CORS App Maven war file deploy to Tomcat

Spring-Boot / Spring Security with AngularJS - Part I (Introduction)

Spring-Boot / Spring Security with AngularJS - Part II (Dynamic resource load from Angular)

Spring-Boot / Spring Security with AngularJS : Part III (Form-based Authentication)





JUnit & Maven Tutorial



JUnit 4 Introduction (Hello World)

JUnit 4 Test with Eclipse Luna (Hello World)

JUnit 4 Test with Maven (Hello World)











Contact

BogoToBogo
contactus@bogotobogo.com

Follow Bogotobogo

About Us

contactus@bogotobogo.com

YouTubeMy YouTube channel
Pacific Ave, San Francisco, CA 94115

Pacific Ave, San Francisco, CA 94115

Copyright © 2024, bogotobogo
Design: Web Master