cho2cee
TIL
cho2cee
전체 방문자
오늘
어제
  • 전체 게시글 (78)
    • Cloud (31)
      • AWS (12)
      • Kubernetes (16)
      • IaC (3)
    • Security (15)
      • ELK (5)
      • Reversing (10)
    • Network (8)
    • Linux (4)
    • Etc. (20)
      • 기타 (4)
      • 업무 (16)

태그

  • CLOUD
  • SAA
  • VPC
  • AWS
  • 합격후기

최근 댓글

블로그 메뉴

  • 홈
  • 태그
  • 방명록
hELLO
cho2cee

TIL

[AWS] EC2 인스턴스에 애플리케이션 설치
Cloud/AWS

[AWS] EC2 인스턴스에 애플리케이션 설치

2021. 11. 10. 00:37

생성한 인스턴스에 웹 서버, 데이터베이스 서버, 애플리케이션 서버를 설치하고 동작하는 것을 확인하자!

 

Nginx 설치 

Amazon Linux 2에서는 yum을 통한 nginx 설치가 지원되지 않기 때문에 yum을 통한 설치 시 에러가 발생한다.

① 그래서 To use, run와 같이 # sudo amazon-linux-extras install nginx1 명령을 이용해 설치를 진행했다.

② Nginx 설치 확인 

[ec2-user@ip-172-31-38-129 ~]$ nginx -v
nginx version: nginx/1.20.0

③ Nginx 서비스 시작 

[ec2-user@ip-172-31-38-129 ~]$ sudo service nginx start
Redirecting to /bin/systemctl start nginx.service

④ EIP로 접속!

 

MySQL 설치 

다음은 애플리케이션 서버와 연동하는 데이터베이스 서버로 MySQL을 설치한다.

① RPM 설치

sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

② yum으로 설치 

sudo yum install mysql-community-server

③ mysqld 실행 

[ec2-user@ip-172-31-38-129 ~]$ sudo systemctl start mysqld

[ec2-user@ip-172-31-38-129 ~]$ sudo systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-12-31 04:10:24 UTC; 17s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 25900 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 25971 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─25971 /usr/sbin/mysqld

Dec 31 04:10:17 ip-172-31-38-129.ap-northeast-2.compute.internal systemd[1]: Starting MySQL Server...
Dec 31 04:10:24 ip-172-31-38-129.ap-northeast-2.compute.internal systemd[1]: Started MySQL Server.

 

웹 애플리케이션 설치 

레일즈(Rails)를 사용해 방금 구축한 MySQL과 연동하는 간단한 CRUD 애플리케이션을 실행해보자!

① 레일즈를 사용하기 위해서는 빌드가 가능한 환경이 필요하므로 빌드에 사용할 패키지를 설치한다.

[ec2-user@ip-172-31-38-129 ~]$ sudo yum -y groupinstall 'Development Tools'

② Ruby와 MySQL 라이브러리도 필요하므로 설치 

[ec2-user@ip-172-31-38-129 ~]$ sudo yum -y install ruby-devel mysql-devel

③ 레일즈에서는 JavaScript 런타임으로 Node.js가 필요하다. 기본 저장소에서는 제공하지 않으므로 EPEL에서 설치

[ec2-user@ip-172-31-38-129 ~]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
[ec2-user@ip-172-31-38-129 ~]$ . ~/.nvm/nvm.sh		//nvm 활성화 
[ec2-user@ip-172-31-38-129 ~]$ nvm install node		//Node.js의 최신 버전 설치 
v17.3.0 is already installed.
Now using node v17.3.0 (npm v8.3.0)
[ec2-user@ip-172-31-38-129 ~]$ node -e "console.log('Running Node.js ' + process.version)"		//Node.js가 실행되는지 테스트
Running Node.js v17.3.0
[ec2-user@ip-172-31-38-129 ~]$
저작자표시 (새창열림)

'Cloud > AWS' 카테고리의 다른 글

[AWS] EBS(Elastic Block Store)  (0) 2021.12.22
[AWS] AWS CLI 사용하기  (0) 2021.11.11
[AWS] EC2 Instance SSH 접속 시 Disconnected Error  (0) 2021.11.09
[AWS] EIP(Elastic IP address)  (0) 2021.11.09
[AWS] EC2 인스턴스 생성, 접속하기  (0) 2021.11.09
    'Cloud/AWS' 카테고리의 다른 글
    • [AWS] EBS(Elastic Block Store)
    • [AWS] AWS CLI 사용하기
    • [AWS] EC2 Instance SSH 접속 시 Disconnected Error
    • [AWS] EIP(Elastic IP address)
    cho2cee
    cho2cee
    Today I Learned

    티스토리툴바