EC2서버에 docker-compose를 사용하여 워드프레스 설치
이번은 docker-compose를 사용하여 EC2서버에 워드프레스를 설치해 볼거다.
$ sudo yum install -y docker
$ sudo service docker start
or
$ sudo systemctl start docker.service
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose"
$ sudo chmod +x /usr/local/bin/docker-compose
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# docker 설치 후 /var/run/docker.sock의 permission denied 발생하는 경우
파일에 권한 변경
$ sudo chmod 666 /var/run/docker.sock
# 이제 유저도 docker 명령어 사용가능
$ nano ./docker-compose.yml
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
$ sudo docker-compose up -d