Install Docker and deploy WordPress blog system
View the version of the system
Docker requires 64 bit CentOS 7
cat /etc/redhat-release
Check the kernel version. Docker requires that the Linux kernel version must be higher than 3.10
uname -r
Uninstall all relevant old versions on this machine
yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-selinux
docker-engine-selinux
docker-engine
Install the yum utility and the necessary software package for Docker
yum install -y yum-utils
device-mapper-persistent-data
lvm2
Configure domestic Docker image resources (University of Science and Technology of China)
Yum -config-manager
--add-repo //mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
Update yum software source cache and install docker ce
yum makecache fast yum install -y docker-ce
View Docker Version
docker --version
Start Docker CE
systemctl enable docker systemctl start docker
Add the current user to the docker group
usermod -aG docker $USER
Test whether the Docker is installed correctly
docker run hello-world
Image acceleration
Docker China's official image acceleration can be accessed through registry.docker-cn.com. At present, the image library only contains popular public images, while private images still need to be pulled from the US image library.
Write the following contents in/etc/locker/daemon. json (if the file does not exist, please create a new one)
{ "registry-mirrors": [" //registry.docker-cn.com "] }
Restart service
systemctl restart docker
Update the system environment
yum update -y
Restart CentOS 7 operating system
reboot
Start Docker service
systemctl start docker
Add the service to the startup item
systemctl enable docker
Search lamp images to find images with more than 10 stars praised by everyone
docker search -s 10 lamp
Pull the selected image, and select the tutum/lamp image here
docker pull docker.io/tutum/lamp
Check whether the image is pulled successfully
docker images
Create a blank directory locally to mount a data volume
mkdir /mysql_data
Create and start a container
docker run -d --name=mylamp -p 8080:80 -p 3306:3306 -v /mysql_data:/var/lib/mysql docker.io/tutum/lamp
Enter the container
docker exec -it mylamp /bin/bash
Initialize MySQL database
mysql_secure_installation
Follow the wizard to complete initialization
Enter current password for root (enter for none):<– Enter for the first run
Set root password? [Y/n]<– Whether to set the root user password, enter y and enter or enter directly
New password:<– Set the password of root user
Re enter new password:<– Enter the password you set again
Remove anonymous users? [Y/n]<- Whether to delete anonymous users, press Enter
Disallow root login remotely? [Y/n]<– Whether to disable root remote login, select n, and then press Enter
Remove test database and access to it? [Y/n]<– Whether to delete the test database, press Enter
Reload privilege tables now? [Y/n]<- Whether to reload the permission table, enter
Open MySQL
MySQL - uroot - p Enter the password set previously
Create Database
create database wp;
Exit MySQL
q
Update apt tool
apt update
Switch to the main directory of the Apache site
cd /var/www/html
Install wget tool
apt install -y wget
Download Wordpress compressed package from official website through wget tool
wget //cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
Extract the downloaded compressed package to the current directory
tar zxf wordpress-4.7.4-zh_CN.tar.gz -C ./
Exit Container
Ctrl + p
Ctrl + Q
View the local IP address and obtain the address to access the wrodpress website
ifconfig
Access through the browser to enter the wp installation configuration page
//:8080/wordpress
Troubleshooting of configuration failure:
-------------------------------------------------------------------------------------
Enter the container
docker exec -it mylamp /bin/bash
Enter the wp configuration directory
cd /var/www/html/wordpress
New Profile
vi wp-config.php
Copy and paste the configuration information provided by the page into the file
Note: In order to avoid garbled code, Chinese notes can be deleted in advance
define(DB_USER, root);
define(DB_PASSWORD, 1111);
define(DB_HOST, localhost);
define(DB_CHARSET, utf8mb4);
define(DB_COLLATE, );
define(AUTH_KEY, XfI2!&IN?sZJ]W>jMy):CRGP 2%ys-? dCAI.Bk@lDPgoh8tj- SNO*D.I/wBgfvey);
define(SECURE_AUTH_KEY, ^%H/yvk_`F?B[+P!eb9[ czr@B } 6$8`f3V4); define(LOGGED_IN_KEY, x2M)5xUfiD/mDZBsXV? EHa>sRHNd$2NMQrz_{Z&M-Fddf{gk%*odMBm7l +uS#~BT);
define(NONCE_KEY, 6~>X:j=J {SabQAO}s_ ; Oy!.+ 4sO6u8J| (~); define(AUTH_SALT, TP::6.oWlTEM4Jnd2`x];2Cz6[,-YDr(-V5%l*kYFlr-<8h|
define(SECURE_AUTH_SALT, *<^uhi,..li@
define(LOGGED_IN_SALT, Fo?B6AQG%6O+-u]SR2asQ#h/BVB=h}XuS??2Ii^h^1xD5,;52+ + 5n@td7qOZYUB7 );
define(NONCE_SALT, ~Vt4^{Sgmxb/*oTeP>k>CjJm-N+~3VB0T[6bCZGLfK-_FRsEJsWCuf_iY5n%D) [F); $table_prefix = wp_;
define(WP_DEBUG, false); define(WP_ZH_CN_ICP_NUM, true);
if ( !defined(ABSPATH) )
define(ABSPATH, dirname(__FILE__) . /);
require_once(ABSPATH . wp-settings.php);
User name/password: ml/1111