¿Cómo instalar Tomcat 9 y dónde alojarlo?

Aprenda a instalar Tomcat y algunas de las opciones de alojamiento en la nube para implementar sus aplicaciones Tomcat.
Esta entrada de blog consta de dos partes: la la primera part talks about how to install Apache Tomcat on Ubuntu by yourself, y la segundo part talks about the best hosting platforms available to host Tomcat applications.
¿Qué es Apache Tomcat?
Apache Tomcat es un servidor web / de aplicaciones de código abierto de la fundación Apache. Anteriormente se llamaba Yakarta. Es un servidor HTTP y un contenedor de servlets. De forma predeterminada, se ejecuta en el puerto 8080.
Tomcat implementa los servlets java y las especificaciones de las páginas del servidor Java. Proporciona un entorno de servidor web Java para que se ejecute el código Java. Apache Tomcat incluye herramientas de configuración y gestión. También se puede configurar directamente editando el archivo de configuración XML.
Aquí hay una guía paso a paso para instalar Tomcat 9 en Ubuntu 18.04.
Requisito previo
Para instalar Tomcat, debe tener java instalado en su sistema.
Actualizaciónate el repositorio e instale Java 8.
sudo apt-get update
sudo apt-get install openjdk-8-jdk -y
Elija Java 8 que acaba de instalar como la versión actual de Java.
sudo update-alternatives --config java
Verifique la versión de Java.
geekflare@geekflare:~$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.10.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
Instalar Tomcat 9
Descarga la latest paquete de la versión Tomcat 9, actualmente su tomcat-9.0.27. Siempre puedes consultar el enlace de descarga oficial para lateprimera versión.
https://tomcat.apache.org/download-90.cgi
El siguiente ejemplo es para 9.0.27.
- Descargue el paquete Tomcat
geekflare@geekflare:~$ wget http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
--2019-11-18 14:29:04-- http://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz
Resolving www-eu.apache.org (www-eu.apache.org)... 95.216.24.32, 2a01:4f9:2a:185f::2
Connecting to www-eu.apache.org (www-eu.apache.org)|95.216.24.32|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10982406 (10M) [application/x-gzip]
Saving to: ‘apache-tomcat-9.0.27.tar.gz’
apache-tomcat-9.0.27.tar.gz 100%[=================================================================>] 10.47M 3.87MB/s in 2.7s
2019-11-18 14:29:38 (3.87 MB/s) - ‘apache-tomcat-9.0.27.tar.gz’ saved [10982406/10982406]
- Extract the Tomcat 9 package
geekflare@geekflare:~$ tar -xzf apache-tomcat-9.0.27.tar.gz
- Por razones de seguridad, crearemosate una separaciónate usuario del sistema para Tomcat.
geekflare@geekflare:~$ sudo useradd -r -m -U -d /home/geekflare/apache-tomcat-9.0.27 -s /bin/false tomcat
[sudo] password for geekflare:
- El usuario de Tomcat debe tener acceso completo al directorio de instalación de Tomcat. Este comando cambia la propiedad del directorio de instalación al usuario de tomcat.
geekflare@geekflare:~$ sudo chown -RH tomcat: apache-tomcat-9.0.27
- Todos los scripts dentro del directorio bin de tomcat deben ser ejecutables, así que agregue el permiso ejecutable.
geekflare@geekflare:~$ sudo sh -c 'chmod +x apache-tomcat-9.0.27/bin/*.sh'
- Create un archivo
tomcat.service
dentro/etc/systemd/system/
para ejecutar tomcat como servicio.
¿Preguntándome por qué? bueno, esto es para asegurar que Tomcat inicia automaticoally cuando el servidor se reinicia.
geekflare@geekflare:~$ sudo gedit /etc/systemd/system/tomcat.service
- Copie y pegue el contenido a continuación en el archivo. Cambiar el
JAVA_HOME
ruta de acuerdo con la ruta de instalación de Java.
[Unit]
Description=Tomcat 9 servlet container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -Djava.awt.headless=true"
Environment="CATALINA_BASE=/home/geekflare/apache-tomcat-9.0.27"
Environment="CATALINA_HOME=/home/geekflare/apache-tomcat-9.0.27"
Environment="CATALINA_PID=/home/geekflare/apache-tomcat-9.0.27"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/home/geekflare/apache-tomcat-9.0.27/bin/startup.sh
ExecStop=/home/geekflare/apache-tomcat-9.0.27/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
- Ejecute el siguiente comando para informar al sistema sobre el nuevo archivo de servicio que acaba de crear.ated.
geekflare@geekflare:~$ sudo systemctl daemon-reload
- Inicie el servicio tomcat.
geekflare@geekflare:~$ sudo systemctl start tomcat
- Compruebe si el servicio Tomcat está en modo de ejecución o no.
geekflare@geekflare:~$ systemctl status tomcat.service
● tomcat.service - Tomcat 9 servlet container
Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2019-11-18 14:41:12 EST; 4s ago
Process: 22939 ExecStart=/home/geekflare/apache-tomcat-9.0.27/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 22947 (java)
Tasks: 14 (limit: 4680)
Memory: 63.0M
CGroup: /system.slice/tomcat.service
└─22947 /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Djava.util.logging.config.file=/home/geekflare/apache-tomcat-9.0.27/conf/logg
Nov 18 14:41:12 geekflare systemd[1]: Starting Tomcat 9 servlet container...
Nov 18 14:41:12 geekflare systemd[1]: Started Tomcat 9 servlet container.
- Puedes pedirle al sistema que automáticamenteally Inicie Tomcat en el momento del arranque ejecutando el siguiente comando.
geekflare@geekflare:~$ sudo systemctl enable tomcat
Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.
- Asegúrese de que su firewall no impida la ejecución de Tomcat. Abra el puerto 8080 en el que se ejecuta Tomcat.
geekflare@geekflare:~$ sudo ufw allow 8080/tcp
Rules updated
Rules updated (v6)
- Editar el
tomcat-users.xml
archivo donde se definen todos los usuarios y roles para la interfaz de administración web de tomcat.
geekflare@geekflare:~$ sudo gedit apache-tomcat-9.0.27/conf/tomcat-users.xml
- También le estoy dando un rol de administrador de usuario de tomcat-gui, que le permite acceder a la interfaz de administración web con una credencial diferente.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<!--
NOTE: By default, no user is included in the "manager-gui" role required
to operate the "/manager/html" web application. If you wish to use this app,
You must define such a user - the username and password are arbitrary. It is
strongly recommended that you do NOT use one of the users in the commented out
the section below since they are intended for use with the examples web
application.
-->
<!--
NOTE: The sample user and role entries below are intended for use with the
examples web application. They are wrapped in a comment and thus are ignored
when reading this file. If you wish to configure these users for use with the
examples web application, do not forget to remove the <!.. ..> that surrounds
them. You will also need to set the passwords to something appropriate.
-->
<!--
-->
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="tomcat" password="admin" roles="manager-gui"/>
</tomcat-users>
- Open your favorite browser and access http://localhost:8080.

- Ahora ve a http://localhost:8080/manager/html, donde está presente el panel web de tomcat. Se le pedirá que inicie sesión, use el nombre de usuario tomcat y la contraseña admin para iniciar sesión. Con esta interfaz, puede iniciar, detener, recargar e implementar una aplicación con solo hacer clic en un botón.

Felicitaciones! Ha instalado correctamente Tomcat 9 en Ubuntu 18.04.
Now the second part about the hosting platforms and their features.
A2 Hosting
Alojamiento A2 platformulario afirma que su alojamiento Tomcat es el más rápido, fácil y confiable. En A2, puedes correr 20 veces más rápido usando el VPS Turbo boost de A2.
They offer 24×7 support with any hosting issue you come across on their platform with a 99.9% uptime guarantee. That makes A2 a very reliable hosting plat.

It gives you enough options to customize the resources you need on the platform. A2 is developer-friendly and gives you the root access to all server’s files, which you are free to edit as per your need. There is a risk-free Anytime Money Back Guarantee in case you do not like the hosting platform and want to stop the usage.
Kamatera
Kamatera is a popular cloud hosting platform. It helps you set up, configure, and launch tomcat in seconds. You can choose the tomcat version you want to host and also the zone (region) where you want to host from a straightforward user interface.

El precio es muy attracthe.
Puede comenzar desde tan solo $ 4 por mes.
Dependiendo de la configuración que elija, existe una amplia gama de opciones de precios ofrecidas por Kamatera. Puede elegir entre una opción de precio mensual o incluso una opción de precio por hora. La mejor parte es que los primeros 30 días son completamente gratuitos.

Virtuozzo
Virtuozzo offers a multi-cloud configuration where you can host applications on different clouds for extra high availability. Here, you can get a combination of PaaS (Platform as a Service) and CaaS (Container as a Service) models.
Con su sencilla interfaz de usuario, puede seleccionar fácilmente la aplicación Tomcat y su versión. Luego, el lanzamiento solo toma unos segundos.

La agrupación automática de Tomcat en Virtuozzo ofrece una función de alta disponibilidad. Entonces, si alguna instancia de Tomcat falla, otra instancia se inicia automáticamente.ally. Su clúster Tomcat puede ser automáticoally escala verticalally y horizonteally en Virtuozzo. Sin embargo, puedes manually escale el horizonte de su clústerally .
Algunas otras características que ofrece Virtuozzo son:
- Soporte para microservicios y aplicaciones heredadas
- Integrarated Herramientas de CI y CD para la automatización
- Configuración rápida de aplicaciones en clúster
- Incorporado monitoring system with alert notification
- IntegrarateComplementos IDE: IntelliJ IDEA, Eclipse, NetBeans
- automated distribución del tráfico para implementación sin ningún tiempo de inactividad
- Compartiendo el entorno y la colaboración de la cuenta con diferentes niveles de acceso
- Marketplace con un amplio conjunto de aplicaciones preconfiguradas para la instalación con un solo clic
JavaPipe
Another hosting platla forma es Servicio de alojamiento Java para Tomcat. Contiene complementos integrados para Hibern.ate, Spring MVC, Servlets y JSP, Grails, Play y muchos más.
Con JavaPipe, you can start with as low as $ 5.40 per month, which gives you dedicated Instancia de Tomcat versiones 7, 8 o 9 con compatibilidad con JDK 7, 8, 10 u 11. Te ofrece 128 MB a 2 GB dedicated RAM and unlimited access to MariaDB. You also get 200 GB of monthly traffic and 5 GB of SSD storage. There are other pricing options also with Java Hosting platform offering more monthly traffic and SSD storage.
Además, obtienes un 40% de descuento si pagas por tres años. Entonces, si puede pensar en un plan de alojamiento a largo plazo, esto podría ser beneficioso.

Conclusión
That was all about Tomcat installation and hosting platforms. If you are interested in hosting Tomcat yourself but on the cloud, then check out estos platFormularios.