Wednesday, May 29, 2013

Automating Tomcat 7 Installation on EC2, Part II

Finalizing the work started in Automating Tomcat 7 Installation on EC2 the user data script was enhanced to modify the following two files:
  • /etc/tomcat7/server.xml
    • change instances of 8080 to 80
    • change instances of 8443 to 443
  • /etc/default/tomcat7
    • change #AUTHBIND no to AUTHBIND yes
And then start the tomcat7 service.  The final user data script is as follows:

#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -q -y
sudo apt-get install tomcat7 tomcat7-docs tomcat7-examples -q -y
sudo sed -i 's/port="8080"/port="80"/' /etc/tomcat7/server.xml
sudo sed -i 's/redirectPort="8443"/redirectPort="443"/' /etc/tomcat7/server.xml
sudo sed -i 's/#AUTHBIND=no/AUTHBIND=yes/' /etc/default/tomcat7
sudo service tomcat7 stop
sudo service tomcat7 start

After starting a new micro Ubuntu 12 instance while providing the script above (as well as using a security configuration which allows/opens port 80 for http traffic), the web server came online and started serving up pages without any further interaction (ie - turnkey tomcat server).




The script could be enhanced further by downloading/deploying a Java webapp (exploded folder or .war file) as needed.

No comments:

Post a Comment