[Build] docker docker-based platform to build wordpress blog site

  WordPress is using PHP language development blog platform, users can support PHP and MySQL database servers set up their own website. Can also WordPress as a content management system ( the CMS ) to use.

  WordPress is a personal blog system , and gradually evolved into a content management system software, which is using the PHP language and MySQL database development. Users can use their blog on a server that supports PHP and MySQL database.

  There are many free WordPress templates developed by third parties, installation is easy to use. But to do its own template, you will need to have some expertise. For example, at least one application you want to know the Standard Generalized Markup Language HTML codes , CSS , PHP and other related knowledge.

Based docker build wordpress blog site platform

1. Custom Network

# Create a docker network LNMP 
[root @ VM_0_10_centos bin] # docker Network the Create LNMP 
3f84590bd82650c47405da35dc0d41700c1b35215fd57d5d7097aeed0387cbbc 

# View docker network information (default only the first 12 the above mentioned id) 
[root @ VM_0_10_centos bin] # docker Network LS 
the NETWORK ID NAME DRIVER SCOPE 
88010dbd06c0 Bridge Bridge local 
Host Host local 221f15f2552e 
3f84590bd826 LNMP Bridge local 
ebe64efe6b83 local none null

2. Create mysql data container

# 先从仓库拉取mysql的镜像
[root@VM_0_10_centos ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
d599a449871e: Pull complete 
f287049d3170: Pull complete 
08947732a1b0: Pull complete 
96f3056887f2: Pull complete 
871f7f65f017: Pull complete 
1dd50c4b99cb: Pull complete 
5bcbdf508448: Pull complete 
a59dcbc3daa2: Pull complete 
13e6809ab808: Pull complete 
2148d51b084d: Pull complete 
93982f7293d7: Pull complete 
e736330a6d9c: Pull complete 
Digest: sha256:c93ba1bafd65888947f5cd8bd45deb7b996885ec2a16c574c530c389335e9169
The Status: the Downloaded newer Image for  mysql:latest
docker.io / Library / mysql: Latest 

# View Mirror 
[VM_0_10_centos the root @ ~] # Docker Images 
the REPOSITORY the TAG ID CREATED the IMAGE SIZE 
mysql Latest d435eee2caa5         10 Days ago Member 456 MB 

# run mysql container -itd to daemon mysql container specified in the background network --mount --network specified data volume provided mysql password -p 3307 -e exposed outside the port, the port 3306 inside the container 
[VM_0_10_centos the root @ ~] # Docker RUN -itd --name -p 3307 --network LNMP lnmp_mysql: 3306-Vol --mount the src = MySQL, DST = / var / lib / 
MySQL = -e MYSQL_ROOT_PASSWORD MySQL password mysql --character-set-server =utf89b7666d5089713fc135c4a695be1725c17a22bf826e46eafe2c52151fdf20948 

# View data volume 
[VM_0_10_centos the root @ ~] # Docker Volume LS 
the DRIVER the VOLUME NAME 
local 6d34aaf134e3298590eab44809adf751d0ca17856bafe57135cf3295230dab6d 
local d18337c811e3cc0ec89552243255bea8b662e18a0b7ecb2a0f95073aceaac702 
local MySQL - Vol 

# MySQL data are placed in this directory data volume 
[VM_0_10_centos the root @ ~] # LS / var / lib / Docker / Volumes / mysql-Vol / _data / 

# to view the mysql log 
[root @ VM_0_10_centos ~] # Docker logs lnmp_mysql 

# view the process container mysql 
[root @ VM_0_10_centos ~] # Docker Top lnmp_mysql

3. Create a database needed

# Into the container to create a database mysql 
[VM_0_10_centos the root @ ~] # Docker Exec Expediting IT lnmp_mysql the bash 
the root 9b7666d50897 @: / # mysql -p # -uroot-carriage, a password 
# Create wordpress Database WP 
mysql> Create Database WP; 
or created directly
# docker exec lnmp_mysql sh -c 'exec mysql -uroot -p "$ MYSQL_ROOT_PASSWORD" -e "create database wp"'

Exit the container, the container view mysql ip address, login by local mysql container

# 查看容器ip
[root@VM_0_10_centos ~]# docker inspect -f '{{.NetworkSettings.Networks.lnmp.IPAddress}}'    lnmp_mysql
lnmp_mysql
172.18.0.2
# 本地访问mysql容器
[root@VM_0_10_centos ~]# mysql -h172.18.0.2 -uroot -p
Enter password: 
# 出现报错
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_p
assword.so: cannot open shared object file: No such file or directory

It may be the version of the problem

[root@VM_0_10_centos ~]# docker exec -it lnmp_mysql bash
root@9b7666d50897:/# mysql -uroot -p
Enter password: 
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> alter user 'root'@'%' identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

# 退出容器,本地登录mysql容器
[root@VM_0_10_centos ~]# mysql -h172.18.0.2 -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.18 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wp                 |
+--------------------+
5 rows in set (0.00 sec)

4. Create PHP environment container

# First searches whether there is the image 
# Docker Search Nginx PHP-FPM- 

# pulling mirror 
[VM_0_10_centos the root @ ~] # Docker pull richarvey / PHP-FPM-Nginx

# Run Mirror == "# create the first container / app / wwwroot directory, or run the file specified directory will be error does not exist 
[root @ VM_0_10_centos ~] # mkdir -p / app / wwwroot
#
--network LNMP needs and linking mysql the container is the same network, or can not connect mysql Ha
[root @ VM_0_10_centos WordPress] # Docker RUN -itd --name lnmp_nginxphpfpm -p 88:80 --network LNMP --link lnmp_mysql: mysql --mount the bind of the type =, src = / app / wwwroot, dst = / var / www / html richarvey / nginx-php-fpm
# Create the index file 
[root @ VM_0_10_centos ~] # vi /app/wwwroot/index.html 
<h1> the Hello World !!! </ h1> 

# this time through the browser http: // ip: 88 there will be just index. html file contents

5. The system set up wordpress blog

# Switch to the source installation directory 
[root @ VM_0_10_centos ~] # cd / usr / local / src / 

# download wordpress (like browser requests error 429, behind me by a friend to help download and upload to the server / usr / local under / src directory. Do not know why I can not download here) 
https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz

# to wordpress extract to / app / wwwroot / directory
[ @ VM_0_10_centos the src the root] # pwd
/ usr / local / the src
[the root @ VM_0_10_centos the src] # -zxvf the tar-4.7.4-zh_CN.tar.gz -C WordPress / App / wwwroot /
[the root @ VM_0_10_centos the src] # LS / App / wwwroot /
index.html WordPress

Accessed through a browser: http: // ip: 88 / wprdpress to

Click to start now, database configuration

PS: Here a database connection error occurred after the investigation is not connected to the lead in the mysql database Runxing wordpress container. Run-top container code has been changed. After the configuration database, will generate a configuration file wp-config.php / app / wwwroot / wordpress / directory

 

Click to install, fill in the information wordpress

 

Click to login, using just created a user name and password

 

 

After logging into your home page

 

So far, the deployment is complete.

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/HeiDi-BoKe/p/11978587.html