[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

Time:2021-11-28

It is recommended to install xftp, which is a software for visual management of files on virtual machine, which is convenient for beginners to learn.

Log in after installation,
[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

Note that if xftp 5 is installed, the protocol is changed to SFTP.

Well, without much gossip, let’s start today’s topic

—How to customize your own website!!!

Step 1: Execute

lnmp add vhost

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

01. Please enter the domain name you want to bind, and then press enter. For example, the domain name I registered with Alibaba cloud is lolong.xyz. Here, I can enter lolong.xyz or any other *. Lolong.xyz to specify a specific website. One host can deploy multiple websites.

After registering the website domain name here, we also need to log in to the personal alicloud account (similar to other platforms), and set the domain name resolution in the console. The legend is as follows:

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

analysis

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

Add resolution

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

↑ host record: must be consistent with the website domain name deployed here
Record value: is the virtual machine IP address
Parsing takes several minutes. This step can be set in advance.

Next, proceed to the operation above the xshell

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

02. Prompt to register more website domain names. If not, press enter directly

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

03. Enter the host file directory corresponding to your domain name and press enter directly. The default is / home / wwwroot / domain name. It is not changed here. Later, it will be adjusted according to different projects.

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

04. Ask whether to add a static rule and press enter directly. Generally, it is URL access

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

05. Do you want to save the access log? Click y and enter

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

06. Enter the name of the saved log and press enter to use the default name

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

07. Whether to create a MySQL database (not required) and press enter

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

08. Finally, click any key to start creating

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

At this point, you have created your own website. You only need to put the items in your hand into the corresponding location and configure them accordingly. See the end for detailed configuration operationsSupplementary notes

If you want to create multiple sites, you can repeat the above operation.

Supplementary notes:

1. How to use and test the site after it is created?

After creating a website by executing LNMP Vhost add, the user-defined domain name (for example, lolong. XYZ) is actually corresponding to the virtual machine / home / wwwroot / lolong.xyz address. When accessing lolong.xyz, the index.html file under the address / home / wwwroot / lolong.xyz is actually accessed.

Test:
Go to this folder / home / wwwroot / lolong.xyz

 cd /home/wwwroot/lolong.xyz

Create and edit index.html

vim index.html

Enter any content and save it: Hello world, this is website

Then visit: lolong.xyz, as shown in the figure

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

02. What if the configuration needs to be changed after the initial site creation?

Modify the corresponding configuration file in the path / usr / local / nginx / conf / Vhost /
It is usually named after your domain name, followed by. Conf.
for example

vim /usr/local/nginx/conf/vhost/lolong.xyz.conf 

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

The operations at the beginning of the article are all modifications to the configuration file.

The following is the nginx configuration content (cross domain and reverse proxy are also added here)

[project launch] detailed step 04: deploy multiple websites on one virtual machine and access the project address by customizing the website name

After modifying the nginx configuration at any time, you must restart nginx in three ways:

First:

/etc/init.d/nginx restart

Second:

service nginx restart

Third:

systemctl restart nginx.service