Last week, my colleague asked me to set up a Wordpress server, and I remember how painful to setup it many years ago. It requires MySQL and PHP. Therefore, it may introduce many security leaks. My website at the moment still can receive Wordpress attack.
Today, I discovered a rapid solution to set up a Wordpress server using Docker, and it also solves the problem with Let's Encrypt.
Let's check it out.
Before we start, if you haven't configured your DNS, please go to DNS manager, setup A record for
www and point them to the server, then we can start.
Step1: Install Docker and Docker-Compose
If you argue, I could have use Kubernetes? Well, you can if you like. I did this for my colleague, which doesn't profit myself much :)
$ apt update && apt upgrade -y
Step 2: Store everything in a directory
$ mkdir ~/wordpress
Step 3: Setup WebProxy
Many thanks to @evertramos, he did everything for setting up the webproxy:
$ cd ~/wordpress
.env with the following content:
Then strat the script:
If you want to configure more options, please check out his repository.
Step 4: Setup Wordpress
Again, thanks to @evertramos, he did everything for setting up the Wordpress:
Also, set up an
.env file and change to corresponding configs:
Then, we are ready to go:
$ docker-compose up -d
Step 5: Setup SFTP
Note that in Wordpress, you will need to set up an SFTP server for the plugin and theme installation.
Activate an SFTP server that dedicated for the Wordpress, the first step is to secure the folder you open to the public:
$ chown -R www-data:www-data content
Then you need to enable the SFTP in SSH config, to edit the configuration, you need:
$ vim /etc/ssh/sshd_config
Then put the following information to the config file:
Match group sftp
Then restart the server:
$ service ssh restart
To use SFTP group, you need:
$ addgroup sftp
Done, and have fun :)