WordPress docker

WARNING: This article may be obsolete
This post was published in 2022-06-11. Obviously, expired content is less useful to users if it has already pasted its expiration date.
This article is categorized as "Garbage" . It should NEVER be appeared in your search engine's results.


Debian安装Docker

Debian安装docker: 🔗 [Install Docker Engine on Debian | Docker Documentation] https://docs.docker.com/engine/install/debian/

也可以使用这个bash script(从docker.com复制过来的):

apt-get update -y

apt install -y sudo vim wget curl

apt-get install -y \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

 sudo mkdir -p /etc/apt/keyrings

 curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

 sudo apt-get update -y

 sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

systemctl restart docker.service

启动Wordpress Docker

docker wordpress: 🔗 [Wordpress - Official Image | Docker Hub] https://hub.docker.com/_/wordpress?tab=description

创建一个文件夹,里面有2个文件:docker-compose.yml和uploads.ini

docker-compose.yml

version: '3.1'

services:

  wordpress:
    image: wordpress:php8.0
    restart: always
    ports:
      - 80:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini


  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

如果要使用wordfence,那么(docker外部的)端口必须为80: 80 :80

如果不使用wordfence,可以设置外部端口为80以外的,比如8888: 8888 :80

下面这个docker-compose.yml文件中,设置了php 8.1,Wordpress使用最新的beta版(比如在2023-03-11,版本为6.2-RC1),端口监听8888,开启debug:

version: '3.1'

services:

  wordpress:
    image: wordpress:beta-php8.1
    restart: always
    ports:
      - 8888:80
    environment:
      # debug mode
      WORDPRESS_DEBUG: 1
      WORDPRESS_DEBUG_LOG: 1

      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini


  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  wordpress:
  db:

uploads.ini

file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600

上线:

$  /usr/libexec/docker/cli-plugins/docker-compose up -d

下线并删除容器:

$  /usr/libexec/docker/cli-plugins/docker-compose down --volumes

下线但不删除容器:

$  /usr/libexec/docker/cli-plugins/docker-compose down


 Last Modified in 2023-03-19 

Leave a Comment Anonymous comment is allowed / 允许匿名评论