This is the fourth episode of the WordPress tutorial. In the first two videos, I analyzed the reasons for using a self-built VPS to build a website, and how to migrate a website from a hosting service provider like SiteGround. This video will talk in detail about how to use a VPS to build and migrate your own WordPress website data. The content includes: website building VPS selection, VPS visualization panel, domain name DNS resolution, SSL certificate application, PHP and MySQL database creation, website basic configuration, Cloudflare basic configuration, as well as precautions when migrating a website and common error solutions. I will try to use one video to explain the basic content of website building.

1. Choose a VPS server

It should be stated that: we are targeting personal independent websites here, which may not have profit requirements. What we pursue is basic security at low cost. Therefore, the core requirement for VPS services is stability, mainly to avoid website disconnection caused by service providers running away, frequent server maintenance, etc. Therefore, you need to find some relatively well-known VPS service providers and choose their special products, with a price range of 10 to 50 US dollars.

I have published several text tutorials and videos on "How to Choose a Special Offer VPS" for this type of service providers. I will put them below the video for your reference. Among them, I would strongly recommend BandwagonHost. Because it has special offers for high-quality lines with direct connections to three networks at a price below $50 per year. It is recommended to wait for it.

Including things like line speed, DDoS attack defense, etc., in fact, as long as you choose the Internet philanthropist Cloudflare for hosting, you can still rest assured. As for website backup, whether it is through a WordPress plug-in or a VPS operation panel, you can set it up yourself.

In addition, regarding GreenCloud, there is a saying that "if the CPU usage is above 30% for a long time, the account will be suspended", and many people recommend not to use it to build websites. Since I have a website temporarily moved to GreenCloud, I will pay attention to it. However, this website has basically no visits, and it is estimated that it is difficult to trigger the CPU30% red line.

2. Install VPS Visualization Panel

After choosing a VPS, the second step is to install a visual operation and maintenance panel for it. The most commonly used and tutorial-filled one is the Pagoda panel. However, the one I used for demonstration is a domestic brand that has been popular in recent years: 1panel. The built-in app store of this panel has a lot of practical software, such as Alist in network storage, Ollama for AI models, and my rigid needs: email server and web page...

1panel installation is very simple:

  • First, connect to the VPS using SSH

If you don't know which SSH tool to use, you can consider finalshell, which supports both Windows and Mac platforms. Friends who use Mac computers can also use Termius. Both tools support SFTP, which is very suitable for friends who don't understand code to directly find, create and modify files.

  • Copy the installation code on the official website and install it

According to the prompts, we will set the login address, account, password and other information.

After the configuration is complete, you can copy all the login information for easy viewing.

If you forget, it doesn’t matter. After logging into the VPS, enter1pctlYou can view the panel information.

  • Finally, log in to the panel and configure

Here we can configure as needed. I usually fill in the server IP in the settings. Other security operations such as binding domain name, enabling SSL, as well as backup, snapshot, etc., you can explore by yourself.

After installing 1panel, the firewall of the VPS will be taken over by it. You can directly view and set the open ports in "System-Firewall". If you don't have ufw installed, you can install it through code. Programs installed through the 1panel App Store can open external access to the port in the advanced settings. If you install the application yourself through code, be sure to allow port access in the firewall.

In addition, if you are using a cloud service provider such as Alibaba Cloud, Tencent Cloud or Amazon Cloud, you must also allow ports in the instance's security policy. Therefore, the problem of application inaccessibility is mostly due to incorrect port forwarding settings.

The easiest way is to copy the application log and paste it into DeepSeek to help you analyze the cause.

3. Configure the operating environment and database

Before installing and configuring the website, we first install the operating environment and database.

Since 1panel has a built-in app store, it is very easy for us to install PHP and MySQL.

1. Install PHP

In the left menu "Website - Operating Environment", select "Create Operating Environment"

Select version 8.4.3, select "Wordpress" for the extended template, and leave the rest as default.

2. Install MySQL

Let’s first go to the app store and install “MySQL”.

Because 1panel's applications are all deployed in Docker mode, when installing the application, pay attention to the "Port External Access" in the advanced settings and make sure to check it.

After the installation is complete, you need to import the website's database information.

  • Import database information

First, we need to create a database account. The username and password are optional, and the permission is "Everyone".

In the remarks, you can specify the purpose of the database to avoid application confusion when there are multiple databases later.

I can write here: the name and date of the website

After the creation is complete, open "Connection Information" in the top menu and copy the connection address of the database container, which will be useful later.

Then in the top menu "Management", select "phpMyAdmin", and then enter: connection address, account number, password in sequence to enter the database backend.

The subsequent operations are similar to exporting database data.

First change the system language to "Simplified Chinese"

Then select your own database, select "Import" in the top menu, select the database file in your computer, click "Import", and wait for the import to be successful.

An easy mistake to make here is not clicking on the database account and directly selecting "Import", which will prompt an error.

4. Hosting Domain Name and Applying for SSL Certificate

Next, you need to host and resolve the domain name, as well as apply for an SSL certificate.

As a hosting service provider, choose Cloudflare, the Internet philanthropist.

1. Domain hosting

If you don't have a Cloudflare account, register one first.

Then select "Add Domain", enter your own domain name, and select "Free Plan". You will then get two DNS server addresses. You need to go to the backend of the domain name registrar (the website where you purchased the domain name) and change the DNS server to Cloudflare's.

Then wait for dozens of minutes or hours, and when you receive the email confirming the successful hosting, you can continue the operation.

2. DNS resolution

Since domain name resolution takes some time, you can set it up in Cloudflare before configuring the website.

Select "DNS" in the left menu and resolve the following according to the differences between IPv4 and IPv6: www, root domain (@), and common subdomain (*).

Taking the IPv4 address 1.1.1.1 as an example, they are: (omitted, see video)

The proxy status can be checked, which not only allows CF to speed up the opening of websites in different regions around the world, but also protects the IP address from being attacked to a certain extent. However, if a specific domain name needs to be pointed to a specific IP, the proxy status needs to be turned off.

3. SSL certificate application

In order to ensure data security and improve user trust, we need to apply for an SSL certificate. Through Cloudflare, not only can we apply for it for free, but the SSL certificate is valid for up to 15 years, which is very conscientious.

In the left menu "SSL/TLS", select "Source Server" and click "Create Certificate".

Do not close the certificate page.

Go back to 1Panel, click "Website - Certificate - Upload Certificate" on the left menu, and copy the certificate and private key. If you are worried about not remembering the purpose of the certificate, you can write it in the notes.

5. Preliminary website configuration

After completing the above preparations, you can start configuring the website.

1. Install OpenResty

If you are creating a website for the first time, you need to install "OpenResty" from the App Store first and follow the prompts to install it.

2. Create a website

  • Click Create
  • Select "Operation Environment" Primary domain name:AAA.com #AAA is your domain name
  • Other domains:www.AAA.com #AAA is your domain name
  • Listen for IPv6: If an IPv6 address is configured, check
  • Code: The system will automatically generate it, the same as the domain name
  • Create FTP: It depends on your personal needs. Since both VPS and 1Panel can view and modify files, you don’t need to configure it.
  • Note: People with more websites can fill it out
    Note: It is not recommended to choose "one-click deployment" in this step, because it will bind the website to PHP, database, and WordPress. The advantage is that it saves trouble, but the disadvantage is that there is a lack of customization space. It depends on personal choice.

3. Basic website configuration

Next, we need to configure the website, click "Website" in the left menu.

  • Domain name settings:AAA.com #AAA is your domain name
  • HTTPS: Check it, select an existing certificate, and save it.
  • Pseudo-static: Select "WordPress" and save

Fill in the rest according to your needs.

6. Import website information

Because I am following the steps for migrating a website, if you are building a new website, it will be slightly different.

Do one thing in advance: delete the "index.php" generated by the system by default.

1. Create a new website

In the above instructions, I omitted the WordPress installation.

If you selected "One-click deployment" before, it will be installed directly.

If you have done nothing, go to the WordPress official website, download the latest Chinese version installation package, and upload it to the website folder (root directory)

Website folder location: "Website-Website-Website Directory", click the "Folder" icon to jump directly. It is recommended to remember it and enter it directly in "System-File" next time.

Then unzip it, and you're done.

2. Import website

Upload the previous website compressed package to the website root directory and then decompress it.

If you are importing from SiteGround like I did, thenPublic.htmlMove all files in the folder to the root directory.

Next, we need to change the folder user group.

  • Modify file permissions

choose"index"Folder, fill in "1000" for both user group and user.

Because we upload files as the root (0) user, but the default user group of the database is 1000. If you do not change it, you will not have permission to execute, modify, or delete files.

  • Modify wp-config.php file

Because we changed the WordPress database, we need to addwp-config.phpModify the relevant content of the database.

Configuration file path:/opt/1panel/apps/openresty/openresty/www/sites/website name/index

** The name of the database for WordPress */ define( 'DB_NAME', '数据库名' ); /** Database username */ define( 'DB_USER', '数据库用户名' ); /** Database password */ define( 'DB_PASSWORD', '数据库用户密码' ); /** Database hostname */ define( 'DB_HOST', 'mysql:3306' );

It should be noted here thathostnameDo not fill in "localhost" or "127.0.0.1". Because we use docker to install MySQL, we need to write "mysql:3306". Otherwise, the website will not be able to connect to the database and report an error. I learned this from the tutorial of the blogger "Qimeng".

At this point, all migration work from the database and website data has been completed.

However, I have some small suggestions about the plugin folder, "plugins" under "wp-content".

7. WordPress plugin processing principles

About the plugin folder, that is, under "wp-content"plugins", I suggest you keep it in the original public file first. The reasons are as follows:

Generally speaking, we use a lot of optimization plug-ins on the website, including images, codes, cache, CDN, etc. If you enable them directly after migration, it will cause many inexplicable errors, such as: web page 403, garbled code, image not displayed, change operation not taking effect, etc.

Therefore, the best way to operate is to move the plugins one by one toplugins In this way, the original plug-in configuration is still there, and it can take effect immediately without reconfiguration.

If you have a lot of plugins, you can also move them by category. But optimization plugins must be moved one by one. This is a lesson learned through blood and tears.

8. Cloudflare Optimization Configuration

Cloudflare's configuration mainly includes three categories: certificate, speed and cache. In simple terms, it means: turn on all free optimization features.

1. SSL/TLS certificate configuration

Because our website forces HTTPS to be enabled, it is best to change the certificate encryption mode to "full" or "strict" to avoid errors when opening the web page.

2. Speed

Just select all the ones that can be checked.

3. Cache

I am still learning about the various cache settings, but there is one setting that must be operated, which is "Bypass the cache in the management background."

Specific operations:

Path: Cache - Cache Rules - Create rules - Bypass cache for all content

Add “/wp-admin/*”

Other settings are for reference only.

Resource TypeMatching PathBrowser TTLEdge TTLApplicable scenarios
Static resources*.css*.js*.png1 year1 yearLong-term framework documents
Pseudo-static pages/*.html2 hours7 daysBlog Post Page
User interaction content/wp-admin/*0 seconds0 secondsBackstage management page

I have been obsessed with Mac mini and Pixel recently, so I haven't had time to optimize the website. I will share it with you after it is debugged.

IX. Common Errors and Solutions

I won’t list all the common errors on websites, but will share some common solutions for your reference.

Generally speaking, after migrating a website, errors are likely to occur due to: database configuration, file permissions, certificate configuration, plugin conflicts, and cache settings.

The first four items are easy to understand. As long as you search for the error code, you can usually locate the cause of the error and then solve it in a targeted manner. However, the way to handle cache is easily overlooked by novices like me.

The most common mistakes are: I deleted a plugin, refreshed the page, and it worked again? I adjusted the theme in the background and cleared the browser cache, but it didn't work? I published an article in the background, but the front-end browser can't see it...

The above errors are most likely caused by cache.

The cached content of our website includes the settings of the optimization plug-in, Cloudflare's browser and edge server cache, and the cache of the computer browser. Therefore, when we want to delete the cached content, we have to deal with them one by one. Once any link is missed, it may become more and more troublesome.

So, when an error occurs on the website, don't immediately start to deal with it after searching for a tutorial. No matter what you change, remember to back up first before operating.

Data is priceless, so you won’t regret it later.

Okay, this video is a bit long. If you find it useful, just follow it.

Since I am also a novice and am still learning WordPress, the content I share is bound to have omissions and errors. You are welcome to correct me in the comment section.

bye-bye~

Related articles:WordPress Tutorials

By Loogn sir

An ordinary person who likes to use fun to resist mediocrity; often writes about his own interests; so you will see technology, digital, entertainment, credit cards, Internet... Refuse to be high-sounding and don't be a pseudo-expert; make professional life-like and biochemistry interesting; well, that's it~

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link