Go to my personal blog https://blognas.hwb0307.com . Welcome to pay attention!
foreword
pass Docker series Do you need a personal blog , you've basically decided whether you want to play a WordPress personal blog. Let's take a look at how to install a WordPress personal blog if you need it!
Note: It is currently not recommended to install WordPress for Docker on machines that do not have port 443 open. After testing, it is very difficult to deploy a reverse proxy and ssl certificate for wordpress on a server that does not open port 443/80. This difficulty is mainly due to the security control of wordpress itself. It may be possible to debug nginx, but the current management method based on Nginx proxy manager (non-80/non-443 port) has not been successful yet. Of course, the more important reason is that if your blog address has a port number, it will give people a very informal feeling.
Start the installation below!
test environment
I tested on my own VPS:
uname -a # Linux VM-12-8-ubuntu 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux docker --version # Docker version 20.10.5, build 55c4c88 docker-compose --version # docker-compose version 1.28.6, build 5db8d86f
Preparation
# Please modify the working directory as needed work=~/docker/wordpress && mkdir -p $work/{db,app} && cd $work # Turn on the firewall and modify as needed sudo ufw allow 4145/tcp comment 'wordpress' && sudo ufw reload # Pull the image ahead of time docker pull mysql:5.7 docker pull wordpress:latest
configure yml file
New file docker-compose.yml:
vim $work/docker-compose.yml
Add the following:
--- version: '3.0' services: db: image: mysql:5.7 restart: unless-stopped environment: MYSQL_ROOT_PASSWORD: rootpassword # Modify as needed MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: yourpassword # Modify as needed volumes: - './db:/var/lib/mysql' networks: - default app: image: wordpress:latest restart: unless-stopped ports: - 4145:80 # Modify as needed. Consistent with firewall open ports. environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: yourpassword # Modify as needed volumes: - './app:/var/www/html' links: - db:db networks: - default networks: default: name: wordpress
direct online service
# Start the service cd $work && docker-compose up -d
ddns-go & NPM
Set up the dynamic domain name resolution of blog.exampledomain.com in ddns-go or domain name hosting background (pointing to the ip of nas).
Set up a reverse proxy in NPM. As shown below:
After the setup is complete, log in directly: https://blog.exampledomain.com
Initialize settings
After visiting https://blog.exampledomain.com, you can see this page, indicating that the installation has been successful:
This is language selection. We choose Simplified Chinese. Click Continue to continue to the next step.
Fill in the relevant information here as needed. A strong password can be generated with bitwarden. For the visibility of this item to search engines, I suggest that you do not tick, search engines can find our blog in the future. **If your blog is very private, you tick it! **Finally click Install WordPress to go to the next step. Similar to:
Finally it worked! You can log in directly by pressing login:
The default background looks like this:
summary
Installing WordPress via Docker in a VPS is really easy. There are no special settings.
Of course, if you use a non-443 port machine, you will be more fortunate (~ ̄▽ ̄)~
WordPress has been successfully installed here. Later we will talk about how to set it up!
Finally, don't forget to use duplicati Backup your WordPress site! Remember how to use it?
Looking forward to more content to come!