显示标签为“EC2 instance”的博文。显示所有博文
显示标签为“EC2 instance”的博文。显示所有博文

2015年6月28日星期日

[方法整理] 关于用Java8开发的webapp在EC2 instance上部署的问题

过程基本上与之前写过的Deploy war file on EC2 instance相同,但是java的版本不一样,所以需要如下操作:

(1)将EC2上默认安装的Java7升级到Java8
(reference:http://serverfault.com/questions/664643/how-can-i-upgrade-to-java-1-8-on-an-amazon-linux-server):
sudo yum remove java-1.7.0-openjdk
sudo yum install java-1.8.0

(2)安装tomcat8:
(reference:http://stackoverflow.com/questions/26637550/how-to-install-tomcat-8-in-amazon-webservices-ec2
yum install tomcat8-webapps tomcat8-admin-webapps

脑洞:关于EC2的security group的设定,今天又犯迷糊了,应该是这样的:


2015年5月9日星期六

[方法整理] Deploy war file on EC2 instance

Deploy war file on EC2 instance

1. Use the following statement to connect to the EC2 instance created:
ssh -i task13-key-pair.pem ec2-user@ec2-52-24-226-141.us-west-2.compute.amazonaws.com

2. Install Tomcat7 on that EC2 instance:(reference: http://in4ray.blogspot.com/2012/04/install-tomcat-7-on-amazon-linux.html)
(1) Initiate SSH session (as 'ec2-user') and connect to the Amazon Linux instance by it public DNS name.
(2) Install Tomcat 7 together with standard Tomcat samples, documentation, and management web apps:
sudo yum install tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps
(3) Start/stop/restart Tomcat 7 as a service.
start:
sudo service tomcat7 start
stop:
sudo service tomcat7 stop 
restart:
sudo service tomcat7 restart 
(4) Add Tomacat 7 service to the autostart.
sudo chkconfig tomcat7 on
  

3. Deploy war file
(1) Add 8080 port to the security group:(reference: http://www.27programs.com/?p=251)
(2) Upload war file
scp -i task13-key-pair.pem task13V1.war ec2-user@ec2-52-24-226-141.us-west-2.compute.amazonaws.com:~/
(3) On your instance console, go to the directory /var/lib/tomcat7/webapps and copy the war file
[ec2-user@ip-172-31-42-83 ~]$ cp task13V1.war /var/lib/tomcat7/webapps/task13V1.war
(4) Restart tomcat by issuing:
sudo service tomcat7 restart  
(5) Access the application from browser