Docker soạn wordpress nginx GitHub

Một thẻ đã tồn tại với tên chi nhánh được cung cấp. Nhiều lệnh Git chấp nhận cả tên thẻ và tên nhánh, vì vậy việc tạo nhánh này có thể gây ra hành vi không mong muốn. Bạn có chắc chắn muốn tạo nhánh này không?

Đây là môi trường phát triển ban đầu giúp bạn bắt đầu và chạy dự án phát triển Wordpress của mình

Bản cài đặt Docker này chứa các tính năng sau

  1. Nginx
  2. PHP fpm
  3. Mysql [Mariadb]
  4. nhà soạn nhạc
  5. WP CLI
  6. người gửi thư
  7. Xdebug
  8. Chứng chỉ SSL tự tạo [Chỉ dành cho phát triển]

điều kiện tiên quyết

Bạn sẽ cần cài đặt Docker trên máy cục bộ của mình

cài đặt

Dưới đây là các bước cần thiết để thiết lập và chạy dự án này

Sao chép repo vào một thư mục cục bộ trên máy của bạn

git clone git@github.com:ilibilibom/Docker-wordpress-ngnix-php-mysql-wpcli-mailcaher.git

Thay đổi các biến sau thành của riêng bạn

  1. trong nginx/mặc định. conf - thay đổi YOUR_DOMAIN thành tên máy chủ của bạn [sau khi thêm miền cục bộ vào tệp máy chủ lưu trữ cục bộ của bạn]

server {
  listen 443 ssl;
  listen 80 ;

  server_name YOUR_DOMAIN;

  ssl_certificate      /etc/certs/nginx.crt;
  ssl_certificate_key  /etc/certs/nginx.key;

  root   /var/www/html;
  index  index.php;

  access_log /dev/stdout;
  error_log /dev/stdout info;

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ .php$ {
    include fastcgi_params;
    fastcgi_pass phpfpm:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  sendfile off;
}

Trong docker-compose. thay đổi tập tin yml

  1. YOUR_ROOT_PASSWORD
  2. CỦA BẠN_DB_NAME
  3. CỦA BẠN_DB_USER
  4. CỦA BẠN_DB_PASSWORD
  5. CỦA BẠN_DOCKER_IP

version: '2'
services:
  mysql:
    image: mysql:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: YOUR_ROOT_PASSWORD
      MYSQL_DATABASE: YOUR_DB_NAME
      MYSQL_USER: YOUR_DB_USER
      MYSQL_PASSWORD: YOUR_DB_PASSWORD
    ports:
      - "3306:3306"
    volumes:
      - "./.data/mysql:/var/lib/mysql"
  phpfpm:
    depends_on:
      - mysql
    image: my/phpfpm:latest
    build: ./docker/php-fpm
    volumes:
      - "./app:/var/www/html"
      - "./docker/php-fpm/php.ini:/usr/local/etc/php/php.ini"
      - "./docker/php-fpm/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini"
    links:
      - mysql
      - mailcatcher
    restart: always
    extra_hosts:
      - "YOUR_DOMAIN:YOUR_DOCKER_IP" # Use the gateway address for your docker network for the ip address. This is so that PHP FPM can find nginx for the postback to do things like cron jobs with WordPress
  nginx:
    depends_on:
      - phpfpm
    ports:
      - "80:80"
      - "443:443"
    image: nginx:latest
    volumes:
      - "./app:/var/www/html"
      - "./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf"
    links:
      - phpfpm
    restart: always
  mailcatcher:
      image: yappabe/mailcatcher
      ports:
          - 1025:1025
          - 1080:1080

QUAN TRỌNG - YOUR_DB_NAME, YOUR_DB_USER, YOUR_DB_PASSWORD là các giá trị bạn thêm vào wp-config của mình. tập tin php

CSONG - DB_HOST trong wp-config của bạn. tệp php phải là - "mysql"

Chạy docker

Chạy

docker-compose build

docker-compose up -d 

Bây giờ, hãy truy cập miền cục bộ của bạn [hoặc ip docker của bạn - nếu bạn chưa thêm miền vào tệp Máy chủ của mình] - bạn sẽ thấy thông báo sau

Yeh !! - Install your PHP aplication here

Cài đặt Wordpress

Bản cài đặt Wordpress của bạn tồn tại trong thư mục

server {
  listen 443 ssl;
  listen 80 ;

  server_name YOUR_DOMAIN;

  ssl_certificate      /etc/certs/nginx.crt;
  ssl_certificate_key  /etc/certs/nginx.key;

  root   /var/www/html;
  index  index.php;

  access_log /dev/stdout;
  error_log /dev/stdout info;

  location / {
    try_files $uri $uri/ /index.php?$args;
  }

  location ~ .php$ {
    include fastcgi_params;
    fastcgi_pass phpfpm:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  sendfile off;
}
0. Đây là nơi bạn bắt đầu cài đặt wordpress

WP CLI

Bạn có thể chạy Wp cli thông qua docker. Để chạy các lệnh wp cli run [thay thế YOUR_PHPFPM_CONTAINER_NAME - bạn có thể tìm thấy nó bằng cách chạy docker ps] và [ YOUR_CLI_COMMAND ] bằng một lệnh thực - ví dụ: tải xuống lõi]

Dockerized Wordpress với máy chủ web NGINX & MariaDB

Wordpress, PHP FPM 7. 4 , NGINX, MariaDB , phpmyadmin , docker & docker-compose

Dễ dàng cài đặt wordpress dưới dạng một docker-compose. dịch vụ yml

Làm thế nào để thiết lập

  • Cài đặt docker & docker-compose trên máy của bạn
  • Tải xuống phiên bản Wordpress mới nhất từ ​​[https. //wordpress. org/] và trích xuất nội dung vào thư mục /www
  • Chạy lệnh này trong thư mục gốc của repo này. docker-compose up -d
  • Điều hướng đến [http. // localhost] trong trình duyệt của bạn
  • Làm theo hướng dẫn cài đặt wordpress với các thông tin đăng nhập kết nối db này [như được cung cấp trong. tập tin env]

Tên cơ sở dữ liệu. tên người dùng wordpress. tên người dùng Mật khẩu. mật khẩu Máy chủ cơ sở dữ liệu. mariadb

  • Đó là nó

Cài đặt wordpress

1- Điền thông số cơ sở dữ liệu cài đặt wordpress từ tệp docker-compose hoặc. tập tin env

Tên cơ sở dữ liệu. báo chí

tên tài khoản. tên tài khoản

Mật khẩu. mật khẩu mở khóa

Máy chủ cơ sở dữ liệu. mariadb

Cài đặt Docker Swarm

  • Cài đặt docker & khởi tạo docker swarm cluster
  • Chạy lệnh này để cài đặt dưới dạng ngăn xếp bầy đàn

docker stack deploy -c docker-compose.yml docker-wordpress-nginx

phpMyAdmin

  • mở url này. máy chủ cục bộ
  • điền thông tin đăng nhập gốc mariadb như chúng tôi đã cung cấp trong. env hoặc docker-compose. yml

ghi chú

  • Repo này chứa Dockerfile php-fpm tùy chỉnh mà bạn có thể chỉnh sửa và xây dựng hình ảnh của riêng mình với php tùy chỉnh. cài đặt ini,
  • cài đặt mặc định là.
    Đặt PHP. ini để thực thi và tải tập lệnh lên

    file_uploads = On
    upload_max_filesize = 64M

    server {
      listen 443 ssl;
      listen 80 ;
    
      server_name YOUR_DOMAIN;
    
      ssl_certificate      /etc/certs/nginx.crt;
      ssl_certificate_key  /etc/certs/nginx.key;
    
      root   /var/www/html;
      index  index.php;
    
      access_log /dev/stdout;
      error_log /dev/stdout info;
    
      location / {
        try_files $uri $uri/ /index.php?$args;
      }
    
      location ~ .php$ {
        include fastcgi_params;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    
      sendfile off;
    }
    
    0
    server {
      listen 443 ssl;
      listen 80 ;
    
      server_name YOUR_DOMAIN;
    
      ssl_certificate      /etc/certs/nginx.crt;
      ssl_certificate_key  /etc/certs/nginx.key;
    
      root   /var/www/html;
      index  index.php;
    
      access_log /dev/stdout;
      error_log /dev/stdout info;
    
      location / {
        try_files $uri $uri/ /index.php?$args;
      }
    
      location ~ .php$ {
        include fastcgi_params;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    
      sendfile off;
    }
    
    1
    server {
      listen 443 ssl;
      listen 80 ;
    
      server_name YOUR_DOMAIN;
    
      ssl_certificate      /etc/certs/nginx.crt;
      ssl_certificate_key  /etc/certs/nginx.key;
    
      root   /var/www/html;
      index  index.php;
    
      access_log /dev/stdout;
      error_log /dev/stdout info;
    
      location / {
        try_files $uri $uri/ /index.php?$args;
      }
    
      location ~ .php$ {
        include fastcgi_params;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    
      sendfile off;
    }
    
    2
    server {
      listen 443 ssl;
      listen 80 ;
    
      server_name YOUR_DOMAIN;
    
      ssl_certificate      /etc/certs/nginx.crt;
      ssl_certificate_key  /etc/certs/nginx.key;
    
      root   /var/www/html;
      index  index.php;
    
      access_log /dev/stdout;
      error_log /dev/stdout info;
    
      location / {
        try_files $uri $uri/ /index.php?$args;
      }
    
      location ~ .php$ {
        include fastcgi_params;
        fastcgi_pass phpfpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    
      sendfile off;
    }
    
    3

  • Thay đổi dockerfile này trong. . /php/Dockerfile

Các tính năng sẽ sớm được bổ sung

  • Đã nâng cấp lên wordpress mới nhất
  • Nâng cấp php lên phiên bản 7. 4
  • Nâng cấp php lên phiên bản 8. x
  • Thêm dịch vụ Trình quản lý tệp vào ngăn xếp này
  • đẩy các thay đổi của bạn vào repo này và gửi Yêu cầu hợp nhất cho tôi

Chủ Đề