Last Updated on 2021-11-05 by Clay
On July 20, 2021, on the second anniversary of my personal website Clay-Technology World (the website you see in front of you), the idea of build a second website suddenly flashed through my mind.
This is something I planned to do a long time ago, but this plan suddenly came to life in my mind, urging me to start to do it, and implying me, "Isn't this the best time?"
So this article was born.
Compared with me who still lacked knowledge of the website two years ago, I plan to use the Linode host to host the website this time because my personal website has been hosted on a shared host. The speed has almost bored me.
So this time I chose the so-called VPS (Virtual Private Server) to build the new website.
And because the website is all Chinese and there is no plan to have a second language at present, the server location should be as close as possible to Taiwan.
Step 1: Buy the VPS host
First, go to the Linode website to buy the host: https://www.linode.com/
Sign up an account, you can go to the Linode management page.
You can choose the host you want to buy. Because the main target customer group of the website I want to build is still Taiwanese, so I chose the Japanese server that everyone recommends; If your target visitors is elsewhere, of course you need to choose the server as close to your destination as possible.
And I chose the cheapest 5 USD/Month plan.
This is because I heard from my friends that it is easy to upgrade, so I first chose the cheapest plan.
After purchasing the host and confirming the boot, we should be able to see the IP address of the host.
Open terminal, use ssh root@your_ip
to connect the host you bought.
The most important thing about the IP address is to point to it for the next purchased domain.
Step 2: Buy the Domain
I went to GoDaddy to buy the domain. I bought it for two years in one go. You can also find the discount code on the Internet.
However, you may have to watch some advertising for unlocking.
After purchasing the domain, we then set up DNS A Record. This is allow the domain we purchased to point to the host of the website we set up.
The setting steps are as follows:
- Log in the GoDaddy Domain Center
- Click Domain button
- Configure DNS
- Edit A Record
- Name/ Host / Alias: @ is mean to point to domain name
- Value / Answer / Destination: Linode host ip address
- TTL: One hour
- Save
Then it will take a few hours for the settings to take effect, so let’s move on to the next step.
Step 3: Log in to the remote server
Log in to the remote computer, update the package library, create a general user account, and add administrator privileges.
ssh root@your_ip
apt update
adduser USERNAME
adduser USERNAME sudo
Then we should prohibit remote login to the root account and set up a firewall, but if we continue to record the content, the content will become too large, so skip it here.
In short, swtich the account you created and start using this host!
By the way, when using commands to operate this host, it is normal if there is a lack of some tools. After all, this is a new host, so just install the missing tool. This article will not repeat them one by one.
Step 4: Deploy WordPress
Step 4-1: Install docker-compose
Here we use docker-compose
to quickly deploy.
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
Output:
docker-compose version 1.29.2, build 1110ad01
If the version number can be displayed successfully, it means the installation has been successful.
Step 4-2: Install WordPress
Create a folder and make the deployment script:
mkdir my_wordpress
cd my_wordpress
vim docker-compose.yml
Write into the docker-compose.yml:
version: "3.9"
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- wordpress_data:/var/www/html
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
wordpress_data: {}
Step 4-3: Execute script
Execute the following command in my_wordpress
folder:
sudo docker-compose up -d
If you don't see any error message, you can open the browser and continue to configure your WordPress website. But if you lack Docker, you can refer: [Linux] Docker Introduction And Creation Step Note