Linux Docker builds a WordPress personal blog (avoiding pits)

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/

image-20230505001030247

image-20230505001202521

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

image-20230503172241938

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

image-20230503172423638

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

image-20230503181158375

Review the list of containers:

sudo docker ps -a

image-20230503181241566

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:

image-20230503181748001

Select the installation language as Simplified Chinese.

image-20230503183333875

Click Start Now to enter the page to configure the mysql database information.

mysql new database wordpress:

image-20230504224844753

image-20230504232147922

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)

image-20230504230233705

Enter the website title, login username, password, etc.

image-20230504235910059

Then the installation was successful.

image-20230504235955986

log in system

image-20230505000249019

The main management interface after login

image-20230505000409496

4. Summary

The above is the process of successfully installing wordpress through docker. If it is helpful to you, please like it~

Guess you like

Origin blog.csdn.net/guigenyi/article/details/130497944