Take you hand in hand to build a personal website from 0, a nanny-level tutorial that Xiaobai can understand

foreword

This tutorial can let Xiaobai learn in 5 minutes! Allows you to easily build your own personal website.


Ready to work

  • Cloud Server
  • Web page source
  • Xshell remote connection tool

Server Description:

You can use well-known domestic brands to purchase servers, such as: Tencent Cloud , Alibaba Cloud , Huawei Cloud , Baidu Smart Cloud
insert image description here

Of course, you can also choose other brands of servers, according to personal preferences.

Take Tencent as an example:

Xiaobai recommends to buy a standard server with 1 core and 2G at the event price.
insert image description here
If you don't catch up with the event, you can purchase a server configured on the official website, and customize the region, system, purchase time, public network broadband according to your personal needs...
insert image description here

For example myself:

Of course I use another brand of cloud server.
View your server after purchase ( 阿里云、腾讯云和这差不多)

insert image description here

Use the Xshell tool to connect to the server

The Xshell tool can be downloaded from Baidu by itself
insert image description here
. After opening, click New,
insert image description here
set properties ,
insert image description here
enter user name, root
insert image description here
enter password
########################################
Note:

Generally, after purchasing the ECS cloud server, the mobile phone SMS will be sent by the Alibaba Cloud system to send an instance creation success message. The content of the SMS includes the login user name and other information.
insert image description here

Linux account name rootWindows server account name administrator
The password cannot be viewed. If you do not remember the password, reset the password on the console. After resetting the password, restart the host to take effect.

########################################
insert image description here
After the connection
insert image description here
is successful, you can change the password

Type the following command and press enter

passwd root

Enter new password Enter new password
insert image description here
again
insert image description here
Password changed successfully
insert image description here

Install web server software

We also need to install web server software to provide website access capabilities, the current mainstream wbe server software: Apache, Nginx, IIS, Tomcat

insert image description here
However, I personally think that the most mainstream is Nginx, so I will use the Nginx server as an example to teach.

Nginx official website

First we have to install Nginx server on Linux

Centos series enter the following command

yum -y install nginx

Ubuntu series enter the following command

apt -y install nginx

We use yum install nginx to install it, unless you are using the Ubantu series of Linux, use the second one.

You may encounter errors when installing Nginx:

No package nginx available.
Error: Nothing to do

insert image description here

The reason for this is that there is no nginx we want in the local yum source, so we need to create a /etc/yum.repos.d/nginx.repo file and add a yum source.

Solution:
Install Ali's yum source

####centos 6版本
curl -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
 
####centos 7版本
curl -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
 
####centos 8版本
curl -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

execute commands in sequence
提示:第一条命令是针对Centos7系统的,如果你非7系统使用考上面你对应版本的命令

#下载阿里yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#清除缓存
yum clean all
#生成缓存
yum makecache
#安装epel源
yum -y install epel-release 

Then re-execute the command to install Nginx:

yum -y install nginx

Installation is complete, insert image description here
run Nginx

Enter the following command to run Nginx

nginx

insert image description here
View port occupancy

Enter the following command to view the port usage

netstat -ntlp

insert image description here
Then directly access the server address, which is the server IP address mentioned earlier.
insert image description here
Enter your server IP address in the browser address bar.
insert image description here
A page appears indicating that nginx has been successfully started.
insert image description here
If your nginx starts, the page is different from mine. Don't worry, because This page is actually the welcome page of nginx (each version of nginx is different), which does not mean that nginx has not started normally.

Change Nginx default page

1nginx默认的文件路径是/urs/share/nginx/html/

If you want to change to your own static page just make the following changes:

Replace the index.html file in the /usr/share/nginx/html directory with your own index.html.

Here's a demo~

Write an html file, the file name is index.html,
insert image description here
open the Xftp tool ,
insert image description here
enter the corresponding directory
insert image description here
, delete the default html file, insert image description here
transmit the html file written by yourself, and
insert image description here
visit the server IP again
insert image description here

可以看到网页变成了我们自己编写的html。

In order to demonstrate that the html writing is relatively simple, you can write some exquisite html and upload it to your own server to build your website.

Guess you like

Origin blog.csdn.net/qq_31762741/article/details/119719271