This is, how to do it on Ubuntu 16 on AWS EC2.
- Install tomcat 8 - follow this: https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-16-04
- In /opt/tomcat/webapps/ create myApp folder [assuming you have myApp.war file to deploy]
- Redirect your domain to ip of your server.
- Redirect port 8080 to 80:
sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 8080
And make it persistent:sudo apt-get install iptables-persistent
- For now, copy to /opt/tomcat/webapps/myApp index.jsp from /opt/tomcat/webapps/ROOT.
- Change ownership of /opt/tomcat/webapps/myApp and its content to tomcat
- In /opt/tomcat/conf/server.xml, before </Engine> tag, add:
<Host name="myApp.com" appBase="webapps" unpackWARs="false" autoDeploy="false"> <Alias>www.myApp.com</Alias> <Context path="" docBase="/opt/tomcat/webapps/myApp" debug="0" privileged="true" /> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="myApp_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" /> </Host>
- sudo systemctl restart tomcat
- Copy myApp.war to /opt/tomcat/webapps/ - it will override existing files and deploy your app
Points 5-10 are necessarily, because tomcat seeing your app in server.xml Host section, trying to redeploy it, causing hang.
Brak komentarzy:
Prześlij komentarz