Instalación Tomcat 8 en máquina vagrant
vagrant
- Vagrantfile
- Vagrant.configure("2") do |config| config.vm.box = "debian/stretch64" config.vm.synced_folder "./data","/vagrant" config.vm.network "forwarded_port", guest: 8080, host: 8080 config.vm.provider "virtualbox" do |vb| vb.name = "tomcat8" vb.memory = 1024 vb.cpus = 1 vb.linked_clone = true end end 
tomcat
/vía: https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
- actualización del sistema:sudo apt-get update 
- instalación Java:sudo apt-get install default-jdk 
- creación usuario/grupo para tomcat:sudo groupadd tomcat sudo useradd -s /bin/false/ -g tomcat -d /opt/tomcat tomcat 
- instalar tomcat (http://tomcat.apache.org/download-80.cgi):cd /tmp curl -O <url_descarga_tomcat> sudo mkdir /opt/tomcat sudo tar xzvf <fichero_tomcat> -C /opt/tomcat --strip-components=1 cd /opt/tomcat sudo chgrp -R tomcat /opt/tomcat sudo chmod -R g+r conf sudo chmod g+x conf sudo chown -R tomcat webapps/ work/ temp/ logs/ 
- automatizar arranque:- obtener el path del ejecutable de Java:sudo update-java-alternatives -l 
- crear el servicio en /etc/systemd/system/tomcat.service:[Unit] Description=Apache Tomcat Web Application Container After=network.target [Service] Type=forking Environment=JAVA_HOME=<path_obtenido_anteriormente>/jre Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid Environment=CATALINA_HOME=/opt/tomcat Environment=CATALINA_BASE=/opt/tomcat Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC' Environment='JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom' ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh User=tomcat Group=tomcat UMask=0007 RestartSec=10 Restart=always [Install] WantedBy=multi-user.target 
- recargar el demonio systemd para que reconozca el servicio:sudo systemctl daemon-reload
- cargar el servicio y comprobar que está OK:sudo systemctl start tomcat sudo systemctl status tomcat 
 
- ajustar el firewall:sudo apt-get install ufw sudo ufw allow 8080 
- si se puede acceder a la pantalla de inicio (http://<ip>:8080) de Tomcat, activar su inicio automático:sudo systemctl enable tomcat 
- configurar acceso a la interfaz web en Tomcat, editando el fichero /opt/tomcat/conf/tomcat-users.xml, y añadiendo un usuario en la sección correspondiente:<tomcat-users ...> <user username="admin" password="password" roles=manager-gui, admin-gui" /> </tomcat-users> 
- si hubiera que modificar las IPs que tienen acceso al interfaz web (por defecto, localhost), habría que modificar:- /opt/tomcat/webapps/manager/META-INF/context.xml
- /opt/tomcat/webapps/host-manager/META-INF/context.xml
 
<Context antiResourceLocking="false" privileged="true" > <!--<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />--> </Context>
- y reiniciar el servicio:sudo systemctl restart tomcat