Install tomcat7
sudo apt-get install tomcat7
Start tomcat7
sudo service tomcat7 start
Stop tomcat7
sudo service tomcat7 stop
Restart tomcat7
sudo service tomcat7 restart
Tomcat7 runs on port 8080 by default. Remember to add port 8080 to the security group in the Amazon EC2 Management Console.
Change from port 8080/8443 to 80/443
sudo vi /etc/tomcat7/server.xml
Enable AUTHBIND
sudo vi /etc/default/tomcat7
# If you run Tomcat on port numbers that are all higher than 1023, then you
# do not need authbind. It is used for binding Tomcat to lower port numbers.
# NOTE: authbind works only with IPv4. Do not enable it when using IPv6.
# (yes/no, default: no)
#AUTHBIND=no
AUTHBIND=yes
Create AUTOBIND permission files
touch /etc/authbind/byport/80
touch /etc/authbind/byport/443
chmod 0755 /etc/authbind/byport/80
chmod 0755 /etc/authbind/byport/443
chown tomcat7:tomcat7 /etc/authbind/byport/80
chown tomcat7:tomcat7 /etc/authbind/byport/443
Restart Tomcat7
sudo service tomcat7 restart
Check if Tomcat is running.
netstat -tulpn
Active Internet connections (only servers)Tomcat7 is running on port 80 as process "java".
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1268/java
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 18848/mysqld
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1268/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 619/sshd
tcp6 0 0 :::22 :::* LISTEN 619/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 431/dhclient3
Deployment root path: /var/lib/tomcat7/webapps
Log path: /var/log/tomcat7
You can change the deployment root path in /etc/tomcat7/server.xml. Search for "webapps".
You will also need to change logging.properties
Search for
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = /vol1/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /vol1/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
CATALINA_HOME and CATALINA_BASE are defined in:
vi /etc/init.d/tomcat7
# Directory where the Tomcat 6 binary distribution resides$NAME is tomcat7
CATALINA_HOME=/usr/share/$NAME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME
Change webapps location to EBS volume:
sudo vi /etc/tomcat7/server.xmlFind
Change appBase to "/vol/webapps" or your desired location.
/vol is the mounted point of a EBS volume. To create a EBS volume, read the post - Amazon EC2 - Mounting a EBS drive.
Restart tomcat7.
Deploy a war file to "/vol/webapps" and access the application at
http://{ec2-domain}/{app_name}
Thanks!
ReplyDeleteKenneth, your post helped me a lot. You are to be congratulated for the excellent material and the contribution they give us. Thank you friend.
ReplyDeleteThanks so much for writing this up. It works for me without any problem.
ReplyDeleteGreat post, thanks a lot!
ReplyDeleteThanks! helped alot!
ReplyDelete