[설치의 정석]
EC2에서 Java-Apache-Tomcat
설치하기
박재호(jrogue@gmail.com)
참고 자료
• <컴퓨터 vs 책> 블로그
• http://jhrogue.blogspot.com/
• OKdevTV 유튜브 방송
• 오늘자 방송:
https://www.youtube.com/watch?v=xJO_Tmcawi8&list=PLdntWJk2tJPJe1
2b_ZV4RnUlMLymtHkvG&index=3
• 설치의 정석 리스트:
• https://www.youtube.com/playlist?list=PLdntWJk2tJPJe12b_ZV4RnUlMLymtHkvG
• 슬라이드 셰어
• https://www.slideshare.net/jrogue/presentations
• ASCIINEMA
• https://asciinema.org/~jrogue
오늘 소개할 내용
• EC2에서 자바 기초 환경 설정하기
• Java+Apache+Tomcat
• 주의:
• 최소 단계로 꼭 필요한 프로그램만 설치한다
• 내가 무엇인지 모르는 행위는 하지 않는다!!!
주의
• 환경은 항상 바뀐다.
• https://sarc.io/index.php/aws/520-aws-ec2-linux-10-apache-tomcat
EC2 설정(1)
• 설치의 정석이므로… EC2는 plain vanilla
EC2 설정(2)
• 보안 그룹에 80(HTTP) 추가
몇 가지 힌트
• 자바는 무엇을 사용할 것인가?
• Corretto8 vs OpenJDK11 → 여기서는 Java 8을 사용(Corretto8은 아마
존에서 LTS로 지원하는 Java 8 구현체)
• Apache → Tomcat 연동에 무엇을 사용할 것인가?
• https://www.lesstif.com/system-admin/apache-httpd-tomcat-
connector-mod_jk-reverse-proxy-mod_proxy-12943367.html → 잘
정리됨. 여기서는 mod_proxy를 활용(설정 간편+AJP같은 WAS 의존적인
프로토콜이 아니므로 성능이 조금 더 높을 가능성)
스크립트(1)
$ sudo yum update –y
$ sudo amazon-linux-extras list | grep corretto
$ sudo amazon-linux-extras install corretto8
$ sudo amazon-linux-extras list | grep tomcat
$ sudo amazon-linux-extras install tomcat8.5
$ sudo yum install tomcat-webapps
$ sudo systemctl start tomcat
$ netstat -na | grep 8080
$ sudo systemctl enable tomcat
$ sudo systemctl is-enabled tomcat
$ curl localhost:8080
1단계_ Java와 Tomcat 설치
스크립트(2)
$ sudo yum install -y httpd
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ sudo systemctl is-enabled httpd
$ curl localhost:80
$ sudo vi /etc/httpd/conf/httpd.conf
$ sudo systemctl restart httpd
$ curl localhost:80
2단계_ Apache 설치와 구성
<VirtualHost *:80>
ServerName sample.example.com
ErrorLog logs/sample.example.com-error_log
CustomLog logs/sample.example.com-access_log common
# Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts)
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
## mapping 80:/ → localhost:8080:/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
웹 브라우저에서 확인
보면서 따라해봅시다~~~
• https://asciinema.org/a/336715

[설치의 정석] EC2에서 Java-Apache-Tomcat 설치하기

  • 1.
  • 2.
    참고 자료 • <컴퓨터vs 책> 블로그 • http://jhrogue.blogspot.com/ • OKdevTV 유튜브 방송 • 오늘자 방송: https://www.youtube.com/watch?v=xJO_Tmcawi8&list=PLdntWJk2tJPJe1 2b_ZV4RnUlMLymtHkvG&index=3 • 설치의 정석 리스트: • https://www.youtube.com/playlist?list=PLdntWJk2tJPJe12b_ZV4RnUlMLymtHkvG • 슬라이드 셰어 • https://www.slideshare.net/jrogue/presentations • ASCIINEMA • https://asciinema.org/~jrogue
  • 3.
    오늘 소개할 내용 •EC2에서 자바 기초 환경 설정하기 • Java+Apache+Tomcat • 주의: • 최소 단계로 꼭 필요한 프로그램만 설치한다 • 내가 무엇인지 모르는 행위는 하지 않는다!!!
  • 4.
    주의 • 환경은 항상바뀐다. • https://sarc.io/index.php/aws/520-aws-ec2-linux-10-apache-tomcat
  • 5.
    EC2 설정(1) • 설치의정석이므로… EC2는 plain vanilla
  • 6.
    EC2 설정(2) • 보안그룹에 80(HTTP) 추가
  • 7.
    몇 가지 힌트 •자바는 무엇을 사용할 것인가? • Corretto8 vs OpenJDK11 → 여기서는 Java 8을 사용(Corretto8은 아마 존에서 LTS로 지원하는 Java 8 구현체) • Apache → Tomcat 연동에 무엇을 사용할 것인가? • https://www.lesstif.com/system-admin/apache-httpd-tomcat- connector-mod_jk-reverse-proxy-mod_proxy-12943367.html → 잘 정리됨. 여기서는 mod_proxy를 활용(설정 간편+AJP같은 WAS 의존적인 프로토콜이 아니므로 성능이 조금 더 높을 가능성)
  • 8.
    스크립트(1) $ sudo yumupdate –y $ sudo amazon-linux-extras list | grep corretto $ sudo amazon-linux-extras install corretto8 $ sudo amazon-linux-extras list | grep tomcat $ sudo amazon-linux-extras install tomcat8.5 $ sudo yum install tomcat-webapps $ sudo systemctl start tomcat $ netstat -na | grep 8080 $ sudo systemctl enable tomcat $ sudo systemctl is-enabled tomcat $ curl localhost:8080 1단계_ Java와 Tomcat 설치
  • 9.
    스크립트(2) $ sudo yuminstall -y httpd $ sudo systemctl start httpd $ sudo systemctl enable httpd $ sudo systemctl is-enabled httpd $ curl localhost:80 $ sudo vi /etc/httpd/conf/httpd.conf $ sudo systemctl restart httpd $ curl localhost:80 2단계_ Apache 설치와 구성 <VirtualHost *:80> ServerName sample.example.com ErrorLog logs/sample.example.com-error_log CustomLog logs/sample.example.com-access_log common # Put this in the main section of your configuration (or desired virtual host, if using Apache virtual hosts) ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ## mapping 80:/ → localhost:8080:/ ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ <Location /> Order allow,deny Allow from all </Location> </VirtualHost> https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
  • 10.
  • 11.