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 …
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.
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...
For example myself:
Of course I use another brand of cloud server.
View your server after purchase ( 阿里云、腾讯云和这差不多
)
Use the Xshell tool to connect to the server
The Xshell tool can be downloaded from Baidu by itself
. After opening, click New,
set properties ,
enter user name, root
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.
Linux account name
root
Windows server account nameadministrator
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.
########################################
After the connection
is successful, you can change the password
Type the following command and press enter
passwd root
Enter new password Enter new password
again
Password changed successfully
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
…
However, I personally think that the most mainstream is Nginx, so I will use the Nginx server as an example to teach.
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
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,
run Nginx
Enter the following command to run Nginx
nginx
View port occupancy
Enter the following command to view the port usage
netstat -ntlp
Then directly access the server address, which is the server IP address mentioned earlier.
Enter your server IP address in the browser address bar.
A page appears indicating that nginx has been successfully started.
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,
open the Xftp tool ,
enter the corresponding directory
, delete the default html file,
transmit the html file written by yourself, and
visit the server IP again
可以看到网页变成了我们自己编写的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.