Build WordPress blog with Docker


I. Introduction to WordPress

WordPress is a personal blog system, and gradually evolved into a content management system software, it is the use of PHP language and MySQL database development, users can support PHP and MySQL database server to use their own blog.

WordPress officially supports Chinese version, and there are third-party Chinese language packs developed by enthusiasts, such as Wopus Chinese language pack. WordPress has thousands of plugins and thousands of theme template styles.

Docker installation

  1. #### Configure the Docker yum source
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Copy the code
  1. #### Install the specified version, here install 3:20.10.7-3.el7
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce- 3:20.107.- 3.el7.x86_64
Copy the code
  1. #### Configure docker image acceleration and modify the CgroupDriver
mkdir /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"]."registry-mirrors": ["https://qtytpky9.mirror.aliyuncs.com"]
}
EOF
Copy the code
  1. # # # # start docker
systemctl start docker && systemctl enable docker
Copy the code

3. Download mysql and wordpress images

You can find the right mysql database at registry.hub.docker.com/.

  1. #### Download the mysql image
docker pull mysql:5.734.
Copy the code
  1. #### Download the wordpress image
docker pull wordpress:4.6
Copy the code
  1. #### View download results, Docker Images
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
mysql        5.734.    09361feeb475   2 weeks ago   447MB
wordpress    4.6       ee397259d4e5   4 years ago   420MB
Copy the code

4. Start mysql and wordpress

  1. #### start mysql, mount data to /home/data/mysqlData and specify utF8MB4 encoding
docker run -v /home/data/mysqldata:/var/lib/mysql --name wordpress_mysql -e MYSQL_ROOT_PASSWORD=123456 -p 13306:3306 -d mysql:5.734. --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
Copy the code
  1. #### Start WordPress and mount the data to /home/data/www/html
docker run -v /home/data/www/html:/var/www/html --name wordpress --link wordpress_mysql:mysql -p 8080:80 -d wordpress:4.6
Copy the code

5. Access and initialize wordpress

  1. #### can now test wordpress by typing http://127.0.0.1:8080/ into your browser, where you can test 127.0.0.1 with your own IP.

2. #### After successful initialization, log in to the home page using the created account

Modify the UEditor plugin as the default post writing plugin

  1. #### Modify the effect before plug-in, plug-in is simpler

2. #### download the ueditor-kityformula-for-wordpress plugin to get jinayang-ueditor-kityformula-for-wordpress-master.zip

Gitee.com/fedkey/UEdi…

  1. #### Install the ueditor-kityformula -for-wordpress plugin

Jinayang – ueditor-kityformula -for-wordpress-master.zip -> install plugin -> upload plugin -> jinayang- ueditor-kityformula -for-wordpress-master.zip The size of the uploaded file exceeds the upload_max_filesize value defined in php.ini.

Htaccess: upload_max_filesize: upload_max_filesize: upload_max_filesize: upload_max_filesize: upload_max_filesize: upload_max_filesize:

CD /home/data/www/html cat >>. Htaccess << EOF php_value post_max_size24M
php_value upload_max_filesize 8M
EOF
Copy the code

The ueditor-kityformula -for-wordpress plug-in is successfully installed, as shown in the screenshot.

  1. #### test writing an article, see the use of the UEditor plug-in, much easier.

Seven,

In addition, the default automatic saving of articles will have multiple versions, which is not what we want, and needs to be modified. It supports disabling automatic saving of articles, disabling the revised version of articles and other functions.


  1. #### To disable the WordPress auto-save and revision code, place the following two codes in the theme template file and do not test
// Disable automatic saving of articles

add_action('wp_print_scripts'.'disable_autosave');

function disable_autosave(a){

wp_deregister_script('autosave');

}

// Disable the revised version of the article

add_filter( 'wp_revisions_to_keep'.'specs_wp_revisions_to_keep'.10.2 );

function specs_wp_revisions_to_keep( $num, $post ) {

return 0;

}
Copy the code
  1. #### Plug-in cleanup

WP-Sweep

  1. #### Changes the file types supported by the Ueditor

./wp-content/plugins/UEditor-KityFormula-for-wordpress/ueditor/php/config.json

  1. #### adjust their favorite style, change the following files

/home/data/www/html/wp-content/themes/alternate-lite/style.css