使用docker-compose安裝wordpress

1.新建一個項目目錄
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# mkdir my_wordpress
root@iZ2ze0ht45qn4m8m1wjfdrZ:~# ls
grid_demo.py  my_wordpress  result.csv  result_gip.csv  result_gzip.csv  shj_test

2.進入my_wordpress目錄

root@iZ2ze0ht45qn4m8m1wjfdrZ:~# cd my_wordpress/
root@iZ2ze0ht45qn4m8m1wjfdrZ:~/my_wordpress#

3.新建一個yml文件vi docker-compose.yaml,包含如下內容:

version: '3.3'

services:
  db:
    image: mysql:5.7
    volumes:
      - dbdata:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress

volumes:
    dbdata:

4.運行docker-compose up -d

admin@iZ2ze0ht45qn4m8m1wjfdrZ:~/Python-3.6.0/my_wordpress$ sudo docker-compose up -d
sudo: unable to resolve host iZ2ze0ht45qn4m8m1wjfdrZ
Creating network "my_wordpress_default" with the default driver
Creating volume "my_wordpress_dbdata" with default driver
Pulling db (mysql:5.7)...
5.7: Pulling from library/mysql
Digest: sha256:691c55aabb3c4e3b89b953dd2f022f7ea845e5443954767d321d5f5fa394e28c
Status: Downloaded newer image for mysql:5.7
Creating my_wordpress_db_1 ... done
Creating my_wordpress_wordpress_1 ... done
admin@iZ2ze0ht45qn4m8m1wjfdrZ:~/Python-3.6.0/my_wordpress$

4.在瀏覽器中打開wordpress,使用yml文件配置的端口8000:localhost:8000

kiHjr.md.png

5.設置用戶名及其餘信息,安裝wordpress

ki24J.md.png

6. 使用用戶名和密碼登陸wordpress

kixHl.md.png

相關文章
相關標籤/搜索