`
woainike
  • 浏览: 77585 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
最近访客 更多访客>>
社区版块
存档分类
最新评论

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" />


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}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics