environment
Install Install Docker dependencies $ sudo yum install -y yum-utils device-mapper-persistent-data lvm2 Install docker-ce $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo $ sudo yum install docker-ce $ sudo systemctl start docker $ docker --version $ sudo docker run hello-world Install docker-compose $ sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose $ sudo chmod +x /usr/bin/docker-compose $ docker-compose --version Write docker-compose.yml $ mkdir ./blog $ cd blog $ sudo vim docker-compose.yml version: '3' services: db: image:mysql:5.7 volumes: #Data volume, mapping local folder - db_data:/var/lib/mysql ports: # If you don't write port mapping, the outside world cannot connect to the mysql (WordPress connection below is fine) - "3306:3306" restart: always environment: MYSQL_ROOT_PASSWORD: xxx MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: #Depends on the db service above -db image: wordpress:latest volumes: - wp_site:/var/www/html ports: - "8000:80" restart: always privileged: true environment: # You can directly use the above service name + port to get the link WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress # Define domain name WORDPRESS_CONFIG_EXTRA: "define('WP_HOME','https://blog.amoyiki.com'); define('WP_SITEURL','https://blog.amoyiki.com');" volumes: db_data: wp_site: Running the container # Start $ sudo docker-compose up -d # Shutdown$ sudo docker-compose down Now you can access it using http://ip:port. If you find that you cannot access it, you can check the container log to find errors. $ sudo docker-compose ps Name Command State Ports blog_db_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp, 33060/tcp blog_wordpress_1 docker-entrypoint.sh apach ... Up 0.0.0.0:8000->80/tcp # The WordPress at the end is the name of the service. This is different from the container name used to view logs in Docker. $ sudo docker-compose logs -f --tail=10 wordpress $ sudo docker-compose logs -f --tail=10 db Use host Nginx to reverse docker wordpress The configuration file of nginx is as follows (irrelevant content omitted) user root; # This is because the WordPress file user in the docker container is www-data server { listen 80; server_name *.amoyiki.com; return 301 https://$host$request_uri; } upstream wordpress-workhorse { server 127.0.0.1:8000 fail_timeout=10s; } server { server_name blog.amoyiki.com; listen 443 ssl; ssl on; ssl_certificate /ssl/path/fullchain.pem; ssl_certificate_key /ssl/path/privkey.pem; access_log /var/log/nginx/access.log main; # WordPress data volume location in the host root /var/lib/docker/volumes/blog_wp_site/_data; location / { proxy_pass http://wordpress-workhorse; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 7d; access_log off; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } Error Collection nginx error Permission denied
Previously, my nginx.conf user used the default nobody, which could not read the user group data of www-data in wp in docker, so I directly promoted the nginx user to root, which can be optimized later. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to use type enhancement without typingscript
>>: mysql 5.7.11 winx64 initial password change
Table of contents 1. Scenario Description 2. Solu...
Online shopping mall database-product category da...
Create a test table -- --------------------------...
<br />Scientifically Design Your Website: 23...
The first one is to use jQuery's ajax to send...
The following code introduces the installation me...
Table of contents 1. Block scope 1.1. let replace...
Table of contents tool: Login scenario: practice:...
Table of contents 1. Rename table method 2. Notes...
1. Installation environment 1. HUAWEI mate x cpu ...
Table of contents 1. Introduction 2. Introduction...
background When you open the product details on s...
need: In background management, there are often d...
Install mysql5.7.18 on CentOS6.7 1. Unzip to the ...
0. System requirements CPU I5-10400F or above Mem...