aws

ec2 에 tomcat7 간단히 설치 하기 - 참 쉽습니다.

mulderu 2013. 5. 15. 17:00

AWS default AMI를 이용한  ec2 instance  에서 tomcat (tomcat7)을 어떻게 설치할까 ???

답은 간단 합니다...

aws repository를 통해 설치 하면 됩니다. (기본적으로 open-jdk6 version 은 ec2  에 설치 되어 있습니다.)

아래는 제가 tomcat7을 설치하고 home page를 올리는 방법을 간단히 처리하는 화면 입니다.


-- 1) yum을 이용하여 tomcat7을 설치 합니다.
[ec2-user@ip-10-10-10-10 ~]$ sudo yum install tomcat7
Loaded plugins: priorities, security, update-motd, upgrade-helper
amzn-main                                                                                                                                                                 | 2.1 kB     00:00     
amzn-updates                                                                                                                                                              | 2.3 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tomcat7.noarch 0:7.0.37-1.24.amzn1 will be installed
...
---> Package tomcat7-servlet-3.0-api.noarch 0:7.0.37-1.24.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                                  Arch                                 Version                                             Repository                               Size
=================================================================================================================================================================================================
Installing:
 tomcat7                                                  noarch                               7.0.37-1.24.amzn1                                   amzn-main                                87 k
Installing for dependencies:
 apache-commons-collections                               noarch                               3.2.1-11.8.amzn1                                    amzn-main                               525 k
 ...                                      noarch                               7.0.37-1.24.amzn1                                   amzn-main                               3.5 M
 tomcat7-servlet-3.0-api                                  noarch                               7.0.37-1.24.amzn1                                   amzn-main                               188 k

Transaction Summary
=================================================================================================================================================================================================
Install      11 Package(s)

Total download size: 6.2 M
Installed size: 7.1 M
Is this ok [y/N]: 
Downloading Packages:
(1/11): apache-commons-collections-3.2.1-11.8.amzn1.noarch.rpm                                                                                                            | 525 kB     00:00     
..........                                                                                                                   | 3.5 MB     00:00     
(11/11): tomcat7-servlet-3.0-api-7.0.37-1.24.amzn1.noarch.rpm                                                                                                             | 188 kB     00:00     
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                            6.8 MB/s | 6.2 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : apache-commons-pool-1.5.6-1.7.amzn1.noarch                                                                                                                                   1/11 
  Installing : apache-commons-dbcp-1.4-7.7.amzn1.noarch                                                                                                                                     2/11 
  .............                                                                                                                          9/11 
  Verifying  : apache-commons-dbcp-1.4-7.7.amzn1.noarch                                                                                                                                    10/11 
  Verifying  : tomcat7-el-2.2-api-7.0.37-1.24.amzn1.noarch                                                                                                                                 11/11 

Installed:
  tomcat7.noarch 0:7.0.37-1.24.amzn1                                                                                                                                                             

Dependency Installed:
  apache-commons-collections.noarch 0:3.2.1-11.8.amzn1                 apache-commons-daemon.x86_64 0:1.0.7-1.5.amzn1                 apache-commons-dbcp.noarch 0:1.4-7.7.amzn1                
  apache-commons-logging.noarch 0:1.1.1-16.8.amzn1                     apache-commons-pool.noarch 0:1.5.6-1.7.amzn1                   ecj.x86_64 1:4.2.1-4.15.amzn1                             
  tomcat7-el-2.2-api.noarch 0:7.0.37-1.24.amzn1                        tomcat7-jsp-2.2-api.noarch 0:7.0.37-1.24.amzn1                 tomcat7-lib.noarch 0:7.0.37-1.24.amzn1                    
  tomcat7-servlet-3.0-api.noarch 0:7.0.37-1.24.amzn1                  

Complete!
[ec2-user@ip-10-10-10-10 ~]$ 

--2) 설치가 잘 되었다는군요 ... 짝짝 !
       그럼 어디에 설치가 되어 있을까요 ???

ec2-user@ip-10-10-10-10 ~]$ whereis tomcat7
tomcat7: /usr/sbin/tomcat7 /etc/tomcat7 /usr/share/tomcat7
[ec2-user@ip-10-10-10-10 ~]$ 

ec2-user@ip-10-10-10-10 ~]$ ls -l /etc/tomcat7
합계 212
drwxrwxr-x 3 root   tomcat   4096 2013-05-15 07:35 Catalina
-rw-rw-r-- 1 tomcat tomcat  12128 2013-02-27 01:18 catalina.policy
-rw-rw-r-- 1 tomcat tomcat   6392 2013-02-27 01:18 catalina.properties
-rw-rw-r-- 1 tomcat tomcat   1394 2013-02-27 01:18 context.xml
-rw-rw-r-- 1 tomcat tomcat    547 2013-02-27 01:18 log4j.properties
-rw-rw-r-- 1 tomcat tomcat   3288 2013-02-27 01:18 logging.properties
-rw-rw-r-- 1 tomcat tomcat   6435 2013-02-27 01:18 server.xml
-rw-rw---- 1 tomcat tomcat   1998 2013-02-27 01:18 tomcat-users.xml
-rw-rw-r-- 1 tomcat tomcat   1449 2013-02-27 01:18 tomcat7.conf
-rw-rw-r-- 1 tomcat tomcat 162905 2013-02-27 01:18 web.xml
[ec2-user@ip-10-10-10-10 ~]$ 

--3)  tomcat 을 실행 합니다.
[ec2-user@ip-10-10-10-10 ~]$ sudo service tomcat7 start
[ec2-user@ip-10-10-10-10 ~]$                             [  OK  ]

ec2-user@ip-10-10-10-10 log]$ sudo su -
[root@ip-10-10-10-10 ~]# cd /var/log/tomcat7
[root@ip-10-10-10-10 tomcat7]# ls
catalina.2013-05-15.log  catalina.out  host-manager.2013-05-15.log  localhost.2013-05-15.log  localhost_access_log.2013-05-15.txt  manager.2013-05-15.log  tomcat7-initd.log
[root@ip-10-10-10-10 tomcat7]# cat catalina.out
tomcat7-7.0.37 RPM installed
May 15, 2013 7:38:21 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 15, 2013 7:38:22 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
May 15, 2013 7:38:22 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
May 15, 2013 7:38:22 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1716 ms
May 15, 2013 7:38:22 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 15, 2013 7:38:22 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.37
May 15, 2013 7:38:22 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 15, 2013 7:38:22 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 15, 2013 7:38:22 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 95 ms
[root@ip-10-10-10-10 tomcat7]# 

-- 4) tomcat 이 어디어 있나요 ??? 
        아래 입니다.

root@ip-10-10-10-10 tomcat7]# pwd
/usr/share/tomcat7
[root@ip-10-10-10-10 tomcat7]# ls -l
total 4
drwxr-xr-x 2 root root   4096 May 15 07:35 bin
lrwxrwxrwx 1 root tomcat   12 May 15 07:35 conf -> /etc/tomcat7
lrwxrwxrwx 1 root tomcat   23 May 15 07:35 lib -> /usr/share/java/tomcat7
lrwxrwxrwx 1 root tomcat   16 May 15 07:35 logs -> /var/log/tomcat7
lrwxrwxrwx 1 root tomcat   23 May 15 07:35 temp -> /var/cache/tomcat7/temp
lrwxrwxrwx 1 root tomcat   24 May 15 07:35 webapps -> /var/lib/tomcat7/webapps
lrwxrwxrwx 1 root tomcat   23 May 15 07:35 work -> /var/cache/tomcat7/work
[root@ip-10-10-10-10 tomcat7]# 
root@ip-10-10-10-10 tomcat7]# cd webapps
[root@ip-10-10-10-10 webapps]# ls

-- 5) root context 를 하나 추가 합니다.. 
       아래와 같이 간단히 추가 합니다.

[root@ip-10-10-10-10 webapps]# mkdir ROOT
[root@ip-10-10-10-10 webapps]# cd ROOT
[root@ip-10-10-10-10 ROOT]# echo "

hi Mulder

" > index.html -- 6) 페이지가 잘 나오는지 확인 합니다. 잘 나옵니다. Okay... [root@ip-10-10-10-10 ROOT]# curl -i -v http://localhost:8080/ * About to connect() to localhost port 8080 (#0) * Trying 127.0.0.1... * connected * Connected to localhost (127.0.0.1) port 8080 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.27.0 > Host: localhost:8080 > Accept: */* > < HTTP/1.1 200 OK HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 Server: Apache-Coyote/1.1 < Accept-Ranges: bytes Accept-Ranges: bytes < ETag: W/"45-1368603858000" ETag: W/"45-1368603858000" < Last-Modified: Wed, 15 May 2013 07:44:18 GMT Last-Modified: Wed, 15 May 2013 07:44:18 GMT < Content-Type: text/html Content-Type: text/html < Content-Length: 45 Content-Length: 45 < Date: Wed, 15 May 2013 07:45:07 GMT Date: Wed, 15 May 2013 07:45:07 GMT <

hi Mulder

* Connection #0 to host localhost left intact * Closing connection #0 [root@ip-10-10-10-10 ROOT]#