Docker deployed WordPress site

WordPress is using PHP language development blog platform, users can set up their own Web site on the server that supports PHP and MySQL database, WordPress blog is not just a program, but also a CMS, many non-blog website is built using WordPress. WordPress general installation method is on the server as PHP, MySQL, Apache / NGINX, then download the WordPress installation package, compile installation; since the docker container appears, WordPress easy to install much faster than before.

Installation Docker
install docker on Centos system is very simple, just need to follow the official website provides the steps below can be recommended to install Community Edition docker-ce also facilitate the maintenance of late.

Install WordPress
Install WordPress involves two important mirrored WordPress and MySQL, only we need to solve these two key docker container, WordPress easy to build on.
1.MySQL installation

docker run -d --privileged=true --name zhouli-mysql -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -p 33306:3306 mysql:5.7.21

① - privileged = true; avoided because the abnormal occurrence of permissions
② - name; container name
③-v; database data mount host specified path, saving data
④-e; MYSQL_ROOT_PASSWORD set root login password
⑤-p; port opening set, if only for internal use can not
supplement: MySQL version of WordPress as much as possible in accordance with the requirements and avoid unnecessary exception occurred

2.WordPress installation

docker run -d --name zhouli-wordpress -e WORDPRESS_DB_HOST=mysql -e WORDPRESS_DB_PASSWORD=123456 -p 1080:80 --link zhouli-sql:mysql wordpress

①-e; WORDPRESS_DB_HOST = mysql MySQL connection specified address, WORDPRESS_DB_PASSWORD connection password is root privileges
② - link; can be connected using self-defined name associated with the container
③-p; 1080 designated port mapping for the next port agent nginx preparing
added: default is to download the latest wordpress docker hub in the mirror
after installation to see whether the normal start two containers

Final commissioning
①nginx port forwarding; the 1080 port mapping to port 80 to provide services to the external network, the following specific examples.

upstream wp {
        server 127.0.0.1:1080 ;
    check interval=1000 rise=2 fall=2 timeout=3000 type=tcp port=1080;
}

server {
    listen       80;
    server_name  www.zhouzhifei.com zhouzhifei.com;
    #access_log /data/log/nginx/zb.access.log main;
    #error_log  /data/log/nginx/zb.error.log;
    root html;
    location / {
        proxy_pass http://wp;
        proxy_set_header Host $host;
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_next_upstream error timeout http_502;
    }
    }

② adjustment https; you can configure SSL certificates in nginx, but more pro-test too need to modify the place, it is recommended to use http normal mode, landing background downloading Really Simple SSL plug-ins, check directly open SSL.

③ About templates; WordPress there are many excellent template, it is recommended to use a Kratos , very suitable for personal blog.

Guess you like

Origin www.cnblogs.com/zhouzhifei/p/11758680.html