This article mainly refers to the article: Docker in action: Docker installs WordPress and quickly builds your own blog
But I stepped on a lot of pitfalls during the reference process, so I hereby record it
1、What is WordPress
Official website : https://wordpress.com/zh-cn/
WordPress is the most widely used open source CMS program in the world. 1/4 of the world's websites are made with wordpress. It was just a personal blog system at first, and then gradually evolved into a content management system software. You can use it to build any website you want. Such as news release websites, corporate portals, personal technology blogs, etc.
This article mainly introduces docker to deploy a WordPress system, and the operating system is based on Ubuntu.
2. Docker quickly deploys WordPress
2.1 First, pull the mirror image of the latest version of WordPress
sudo docker pull wordpress:latest
2.2 install mysql
Wordpress is based on php+mysql, so you need to install the mysql database, which I have already installed.
ip: 192.168.31.31 port: 3307 account: root password: 123456
View the list of containers:
sudo docker ps -a
The name of mysql is [mysql].
2.3 Running wordpress container
sudo docker run --name wordpress --link mysql -p 1080:80 -d wordpress
Parameter Description:
[–name]: Set the container name to [wordpress]
[–link]: link to the name of the MySQL container [mysql]
[-p 1080:80]: port mapping, mapping port 1080 of the host to port 80 in the container (wordpress occupies port 80 by default)
The last [wordpress]: point to the wordpress container pulled down in step 2.1
Review the list of containers:
sudo docker ps -a
You can see that wordpress has been installed.
2.4 docker set the wordpress container to start automatically
sudo docker update --restart=always wordpress
2.5 Firewall settings
Close the firewall or open port 1080, choose one of the two.
turn off firewall
systemctl stop firewalld
Firewall open port 1080
systemctl status firewalld #查看防火墙状态
firewall-cmd --list-ports #查看开放端口
#设置1080端口开放
firewall-cmd --zone=public --add-port=1080/tcp --permanent
firewall-cmd --list-ports #再次查看是否开放
3. Browser access wordpress
Enter 127.0.0.1:1080 in the browser to access wordpress. Open the page as follows:
Select the installation language as Simplified Chinese.
Click Start Now to enter the page to configure the mysql database information.
mysql new database wordpress:
The host name must be filled with ip:port (it is said that if it is localhost+port, an error will be reported, and the reason is unknown)
Enter the website title, login username, password, etc.
Then the installation was successful.
log in system
The main management interface after login
4. Summary
The above is the process of successfully installing wordpress through docker. If it is helpful to you, please like it~