---
# System prepended metadata

title: 20230508 社團課 - WordPress安裝
tags: [社課]

---

---
title: 20230508 社團課 - WordPress安裝
tags:
- 社課
---
# 20230508 社團課 - WordPress安裝
### 步驟一 -- 安裝 Docker Composer
```
sudo apt update
sudo apt install docker-compose
```

### 步驟二 -- 建構Docker程式資料夾與清單
```
sudo mkdir ~/docker
sudo vim ~/docker/docker-compose.yml
```
#### ------docker-compose.yml內容 
```
version: '3'
services:
  wordpress:
    image: wordpress
    container_name: wordpress
    ports:
       - 80:80
    restart: always
    environment:
      WORDPRESS_DB_HOST: mariadb
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: "設定密碼"
      WORDPRESS_DB_NAME: wordpress
    volumes:
      - ./Wordpress/config:/usr/local/etc/php/conf.d/uploads.ini
      - ./Wordpress/html:/var/www/html
  mariadb:
     image: mariadb:10.7
     container_name: mariadb
     ports:
        - 3306:3306
     environment:
        MYSQL_ROOT_PASSWORD: "設定密碼"
        MYSQL_DATABASE: wordpress
        MYSQL_USER: wordpress
        MYSQL_PASSWORD: "設定密碼"
     restart: always
     volumes:
         - ./MariaDB/var/lib/mysql:/var/lib/mysql
         - ./MariaDB/etc/mysql/cond.d:/etc/mysql/conf.d
     command: ['--lower_case_table_names=1','--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
```
## 讓Docker-Compose去抓檔案與建構程式
```
cd ~/docker
sudo docker-compose down -v                         #目的為刪除舊檔案
sudo docker-compose up -d --remove-orphans
```
