Install Tomcat 7 on Amazon EC2 Ubuntu

Install Tomcat 7 on Amazon EC2 Ubuntu

 
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
123456789101112
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
 
<!-- change the ports from 8080 and 8443 to 80 and 443 respectively -->
 
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="443" />
view raw gistfile1.txt This Gist brought to you by  GitHub.


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)
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  
Tomcat7 is running on port 80 as process "java".

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
CATALINA_HOME=/usr/share/$NAME
# Directory for per-instance configuration files and webapps
CATALINA_BASE=/var/lib/$NAME
$NAME is tomcat7


Change webapps location to EBS volume:
sudo vi /etc/tomcat7/server.xml
Find
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}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值