일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- kubernetes #k8s
- 11003
- aws #docker #mysql #heidisql
- 백준 #9655
- fe
- frontend
- 백준 #7568
- 구름톤유니브
- 백준 #2292
- javascipt
- 3015
- Context API
- 17298
- vite
- 카카오테크 부트캠프 클라우드 in 제주
- Web
- aws #docker #tomcat
- ErrorBoundary
- aws #kubernetes
- 9251
- 백준 #23971
- 백준
- C++
- JS
- aws #docker
- 백준 #5073
- 백준 #1157
- 30504
- 2493
- react
- Today
- Total
gmlwlsl 님의 블로그
[AWS, Docker] Nginx Container로 html 페이지 띄우기 + 워드프레스 본문
EC2 spec
- AMI : Ubuntu 22.04
- type : t2.medium
- SG : 모든 TCP/UDP/ICMP 허용
- DiskSize : 10GB
- Subnet : public

실습 (Cloud shell or terminal)
terminal의 경우 아래 조건이 충족되어야 함
- aws 실행 가능한 패키지 설치
- aws 접속 가능한 액세스 키 발급
1. awscli 설치
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ unzip awscliv2.zip
$ sudo ./aws/install
2. awscli 자격증명
access key, secret key, region은 꼭 복사해 두기
$ aws configure
{access key}
{secret key}
{region}
$ describe-instance
3. Docker 설치
# Add Docker's official GPG key:
$ sudo apt-get update
$ sudo apt-get install ca-certificates curl
$ sudo install -m 0755 -d /etc/apt/keyrings
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
$ sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt-get update
https://docs.docker.com/engine/install/ubuntu/
Install Docker Engine on Ubuntu
Jumpstart your client-side server applications with Docker Engine on Ubuntu. This guide details prerequisites and multiple methods to install Docker Engine on Ubuntu.
docs.docker.com
4. Container 생성, 실행, 삭제
$ docker container run -d --name nginx1 -p 8001:80 --restart always nginx
$ docker container run -d --name nginx2 -p 8002:80 --restart always nginx
5. 페이지 띄우기
$ docker container run --name web1 -d -p 8883:80 -v /root/docker/web:/usr/share/nginx/html --restart always nginx
* /root/docker/web : 기본 웹 디렉토리, index.html 경로
* -v : 볼륨 연결 제공. 내 ubuntu linux의 /root/docker/web 디렉토리를 web1 container의 /usr/share/nginx/html 과 연결시킴
-> 나의 upuntu ip:8883 접속 시 페이지 확인 가능
+ 워드 프레스 사용법
1. DB Container 생성
$ docker container run -d --name wpdb -v wpdbvol:/var/lib/mysql --restart=always -e MYSQL_ROOT_PASSWORD=test123 -e MYSQL_DATABASE=wordpress mysql:5.7
2. 워드 프레스 Container 생성
$ docker container run -d --restart=always -p 8881:80 --name=wp -e WORDPRESS_DB_PASSWORD=test123 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_DB_USER=root --link wpdb:mysql -v wpvol:/var/www/html wordpress
3. 배포
📍 부트스트랩에서 free template 다운해서 빠르게 반응형 사이트를 만들 수 있음
'-d' 는 백그라운드에서 실행 용
'-p' 는 앞에서 보이는 용
'Visualizer' 카테고리의 다른 글
[AWS, Docker] Tomcat Container 만들고 war 배포하여 application 실행하기 (0) | 2024.06.27 |
---|---|
[AWS, Docker] docker-compose 실습 (0) | 2024.06.27 |
[AWS, Docker] 직접 Docker Image 만들기, repo에 push (Orchestration) (0) | 2024.06.27 |
[AWS, Docker] Docker Container, HeidiSQL을 통해 MySQL 접속하기 (0) | 2024.06.27 |
[Docker] 개념 정리 (0) | 2024.06.27 |