Home  >  Article  >  CMS Tutorial  >  Use docker to build wordpress

Use docker to build wordpress

藏色散人
藏色散人forward
2019-09-21 10:09:485540browse

The following column WordPress Tutorial will introduce how to use docker to build wordpress. I hope it will be helpful to friends in need!

Use docker to build wordpress

Introduction

This is not a formal article about setting up wordpress, it is based on the previous article On the basis of implementation. The final implementation is to use nginx as a proxy, an independent wordpress container, and MySQL connected to laradock as storage.

Modify nginx proxy

Compared with laradock's configuration, you only need to modify the listening domain name and forwarded port. Create a new wordpress.conf file in the /etc/nginx/conf.d/ directory, as follows

server {
    listen  80;
    server_name  blog.you_site.com;
    location / {
        proxy_set_header  Host  $http_host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass  http://[宿主机IP]:8001;
    }
}

Remember to restart after modification

Build the wordpress container

1. Pull the image docker pull wordpress

2. Because wordpress needs to connect to the MySQL container, laradock happens to be available, so just use this. The connection method does not use --link, use --network. You can refer to the MySQL network in

3.laradock, which is written in the docker-compose.yml file, as follows

Use docker to build wordpress

At the same time, use docker network ls to view, and you can see the laradock_backend network. Obviously you can use laradock_backend

1. Build a container docker run -d --name wordpress -p 8001:80 --network laradock_backend wordpress

2. The last step is to start the server (host) Port 8001

Conclusion

Open the website and the configuration interface appears. Just set Database Host to mysql. Other data tables, users, etc. are not within the scope of discussion.

The above is the detailed content of Use docker to build wordpress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete