Apache Tomcat, or simply Tomcat as it is more well known, is an open-source web container with servlets and JavaServer Pages support Application (JSPs) developed by the Apache Software Foundation. The Tomcat servlet engine often presented in combination with the Apache web server, as it presents the Java code necessary to execute it to the environment.
In its simplest form, Tomcat executes a single operation within the system through a process in the Java Virtual Machine. Each subsequent HTTP request from a browser to Tomcat is processed in a separate thread, since Tomcat has the necessary tools and configuration to manage them. Tomcat's configuration is stored in simple XML files that can be reviewed and edited with a multitude of tools. In the next tutorial We will teach you how to install this useful tool on your Ubuntu 15.10 Server system, which for now reaches version 8.
Tomcat 8 installation
Installing Tomcat 8, if you have not included it by default in your system installation, is as simple as entering the following commands from the terminal:
sudo apt-get install tomcat8 tomcat8-docs tomcat8-admin tomcat8-examples
Answer affirmatively to the question if you want to install Tomcat. This will also include the dependencies it has on the Java packages and will create the tomcat8 user within your system. In addition, the application will start with its default parameters.
If you want to try the application access your domain or IP address of the machine followed by port 8080 from any browser.
http://your_ip_address:8080
You will then see a text stating "It works!", Along with some other additional information.
Tomcat 8 commit
Tomcat 8 configuration can be modified from the management web interface itself. To enable it and all its functionalities you will have to edit the file located in /etc/tomcat8/tomcat-users.xml
sudo vi /etc/tomcat8/tomcat-users.xml
Add the following lines:
<role rolename="manager"/> <role rolename="admin"/> <user name="admin" password="secret_password" roles="manager,admin"/>
Save and quit editing the file. Now you should be able to see and manage the server from the address http://tu_dirección_ip:8080/manager/html. You can access with the name and password that you have established in /etc/tomcat8/tomcat-users.xml.
En / var / lib / tomcat8 are the directories conf, logs, webapps y work. En webapps is where the servlets will be hosted (or at least the XML configuration file pointing to them).
As a way to test the server, you can download the following application file and deploy it through the management page (within the section of deploy you can see the button to upload the file to your server). Optionally you can execute the following command from the directory webapps de Tomcat y the server will automatically recognize the web application file and expand it without further intervention on your part:
wget http://simple.souther.us/SimpleServlet.war
Now, enter the following path in your browser: http: //your_ip_address:8080 / SimpleServlet /
How to configure Tomcat to listen on port 80
If you want change Tomcat listening port to 80 you must follow the following procedure. First edit the file located in /etc/tomcat8/server.xml.
sudo vi /etc/tomcat8/server.xml
Then find the text where it says Connector port = »8080 ″ and replace that value with Connector port = »80 ″. Save and exit the file editing mode.
Now you just have to restart the Tomcat server with the following command:
sudo /etc/init.d/tomcat8 restart