How to build your own Internet territory from 0 to 1 with Tencent cloud

Time:2021-11-20

Reason for recommendation:

Today, I saw an article in Tencent cloud technology community – Tencent Pavilion. I feel it is very helpful for us white people to enter the Internet. It makes me re understand the deployment and architecture of the cloud, as well as the cloud server, cloud database, CDN, cloud security, Vientiane pictures, cloud on demand and other products. Here, I also want to share it with you, I hope it will be of some help to you.

The following is the original text of the article:

Project introduction

By using a variety of Tencent cloud products (CVM, CDN, CDB, cos, SSL certificates) and the well-known CMS system WordPress, we can create a private plot in the Internet space from scratch.

How to build your own Internet territory from 0 to 1 with Tencent cloud

CDN (content distribution network), cos (object storage), CDB (cloud database) and SSL certificate are optional functions. The following demonstration environment will explain the configuration of the complete topology mode and the configuration of the most basic mode (ECS only).

Pre war preparation

Have a domain name that has been successfully registered in Tencent cloud.
Open a CVM machine and record the IP, account and password in a document.
The battle begins

The machine used in the tutorial is the CentOS 7.2 64 bit version image in Tencent cloud public image, and the cloud hard disk is purchased to store business website programs separately. The one click LNMP (Linux + nginx + MySQL + PHP) tool of oneinstack is used to build the production environment.
1. First log in to our ECs, update and add dependencies and developer tools

yum -y update && yum -y groupinstall “Development Tools”

How to build your own Internet territory from 0 to 1 with Tencent cloud

2. Mount and use the cloud disk as the data disk

wget https://soft.vtrois.com/scrip…
chmod +x auto_fdisk.sh
./auto_fdisk.sh

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: the cloud disk to be automatically mounted needs to be filled in step 3 and the location to be mounted needs to be filled in step 5. Because the default data location of oneinstack is / data, fill in / data here and wait for the script to execute.

3. Download and use oneinstack’s one click LNMP tool to build the production server

yum -y install wget screen curl python
wget http://mirrors.linuxeye.com/o…
tar xzf oneinstack-full.tar.gz
cd oneinstack
screen -S oneinstack
./install.sh

How to build your own Internet territory from 0 to 1 with Tencent cloud

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: for security reasons, in the first step, I changed the default SSH port 22 to 53185. In the second step, I chose to install only the nginx service (the compiled version of openresty is selected here). In the third step, I chose to install the database version (the stable version of MySQL 5.6 I chose here. If I use cloud database, I don’t choose to install the database service), In step 4, select the version of PHP to install (here I choose the latest version 7.1). You can choose winscp tool to replace FTP tool. After configuration, there will be an option to restart the server.

4. Create and configure a virtual machine

How to build your own Internet territory from 0 to 1 with Tencent cloud

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: use the. / vhost.sh command to run the new virtual machine script. In the first step, select whether to enable the SSL Protocol (if not, enter n). In the second step, fill in the registered domain name. In the third step, select whether to forcibly jump to HTTPS (if n is entered in the first step, this step will not appear at this time). In the fourth step, turn on the WordPress pseudo static function, Wait until the configuration is completed.

5. Create a new database (if cloud database is used, this step will not be required)

When building the LNMP environment, select the root account where phpMyAdmin tool is installed to log in. The login address is Internet IP / phpMyAdmin (example: 123.206.66.153 / phpMyAdmin). Create a new database called blog, and then create a new ordinary user vtrois and assign the permission to the blog library. Here, you can also use the SQL command (this one is also to make your data more secure. Of course, the safest solution is to use the method of station library separation and the method of read-write separation. Station library separation will be used in the cloud database).

GRANT ALL PRIVILEGES ON blog.* TO ‘vtrois’@’%’ WITH GRANT OPTION;

How to build your own Internet territory from 0 to 1 with Tencent cloud

6. Configure and import SSL Certificate (not required)

How to build your own Internet territory from 0 to 1 with Tencent cloud

Find the SSL certificate management in the cloud product category of the console, click apply for certificate to apply for a TrustAsia DV SSL CA – G5 certificate for one year free, select self-service DNS authentication for authentication, bind CNAME records according to the prompts given and wait for background automatic authentication, and a set of certificate files will be obtained if the application is successful. Here we select the certificate used in nginx environment, And rename the obtained certificate to the format of domain name. CRT and domain name. Key, for example: (qcloud.vtrois.com.crt and qcloud. Vtrois. Com. Key), then upload the renamed certificate to the server / usr / local / openrest / nginx / conf / SSL and replace the original file, and finally execute the command to restart nginx service at the terminal.

service nginx restart
7. Configure and use cloud database (not required)

Cloud database will provide you with a slave database free of charge, so as to achieve the uninterrupted service of master-slave synchronization, and support the return of files in any time period within 3 days and the download of cold standby data within 5 days. The high configuration version can also open read-only instances to realize the separation of reading and writing. It is a conscience product close to the people, saving a lot of maintenance time. Similarly, after purchasing the database instance, initialize the password for creating the default root account and enter the console. It is recommended that you create a common account to manage separate database files like self built databases (this process can be completed in the cloud database console according to the product instructions).

How to build your own Internet territory from 0 to 1 with Tencent cloud

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: ECs and cloud database should be in the same region and the same available area, otherwise the data cannot be interconnected. However, at present, Guangzhou zone 1 and Guangzhou zone 2 can be interconnected.

8. Download and install the WordPress program

cd /data/wwwroot/qcloud.vtrois.com
wget http://wordpress.org/latest.t…
tar xzvf latest*
cd wordpress*
sudo rsync -avz . /data/wwwroot/qcloud.vtrois.com
cd ..
rm -rf latest.tar.gz
rm -rf wordpress
sudo chown -R www /data/wwwroot
sudo chgrp -R www /data/wwwroot
Open the site qcloud.vtrois.com in the browser to enter the WordPress installation interface. The first step is to configure the database information, where database host is the database address. If you use a local self built database, use the default localhost. If you use a cloud database, fill in the intranet IP of the database and click Submit.

How to build your own Internet territory from 0 to 1 with Tencent cloud

In the next step, the site information will be configured. It is recommended to use the automatically generated password, and then click Install.

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: the first CD command enters the newly created domain name directory (here I use qcloud. Vtrois. Com). The chown and chgrp commands modify the users and groups to which the file or directory belongs.

How to build your own Internet territory from 0 to 1 with Tencent cloud

9. Enable CDN content distribution function (not required)

Because our site is built on a server, its physical location is fixed. For example, I choose to buy a machine in the Beijing computer room. However, if users visit Shenzhen in the south, there will be a certain delay in the access process. At this time, we can choose to use CDN service to optimize the process, At the same time, CDN service can also be used to resist the problems of network paralysis and service unavailability caused by DDoS at the source station.

How to build your own Internet territory from 0 to 1 with Tencent cloud

Note: for cache configuration, please refer to the configuration settings in the figure above. For strong DDoS resistance, please refer to the configuration settings in the figure below (the threshold setting can be adjusted according to the normal traffic). If SSL is enabled, you need to add a certificate in certificate management and bind it to the domain name.

How to build your own Internet territory from 0 to 1 with Tencent cloud
10. Correctly and reasonably configure the security group without leaving opportunities for hackers

How to build your own Internet territory from 0 to 1 with Tencent cloud
Note: configure the security group according to the SSH port 53185 configured before and the 80 and 443 ports of nginx. At the same time, when we build the LNMP environment, the system creates a new test page by default (index.html, ocp.php, phpinfo.php, tz.php in / data / wwwroot / default). We need to delete it, If you need to use phpMyAdmin, remember not to delete the phpMyAdmin folder in default.

Battle victory

At this time, you have completed the creation from scratch and safely configured your private plot. The rest is left to you, such as writing personal experience, learning notes, etc. you can also get Kratos theme on GitHub to add color to your blog.
How to build your own Internet territory from 0 to 1 with Tencent cloud

Write at the end

If you have any questions you don’t understand in the article during the attempt, you can leave a message at the bottom of the article, and I will reply to you one by one, just for fun!
This article is from Tencent cloud technology community
(embedded text chain)https://www.qcloud.com/commun…

Recommend everyone to pay attention to Tencent cloud technology community WeChat official account: QcloudCommunity
How to build your own Internet territory from 0 to 1 with Tencent cloud