Nginx deploys front-end static website detailed teaching (step by step)

foreword

Simple deployment of static websites using Xshell, Xftp, and Nginx from scratch requires cloud servers (Alibaba Cloud, Tencent Cloud, Huawei Cloud, etc.)

1. Download and install Xshell and Xftp

  XShell is used to operate the server from the command line, and Xftp is used to upload and download files to the server

  Official download link: NetSarang Homepage CN - NetSarang Website

 Select Free Edition at the bottom of the page

 Fill in the correct name and email address, and you can download the free software after receiving the email. If you install it, it will be ok if you continue to next.

2. Create a new session connection server

Steps:  Open Xshell to create a new session link --> enter the server name (customizable) --> enter the host ip address (server public network ip) --> port number --> default other content --> click OK

 

 

 

Enter the command to check whether the connection is successful:

cd /
ll
ping baidu.com
都可以访问,即连接成功 !

As shown in the picture:

Three. Nginx server

Nginx official website:

①Install yum dependencies

yum install yum-utils

②Add yum source file

cd /etc/yum.repos.d/
# 添加nginx的yum源码
vim nginx.repo

# 或 直接新建 nginx.repo 文件
vim /etc/yum.repos.d/nginx.repo

# 按下键盘中 “i” 键 进入编辑状态

③Add configuration information to the nginx.repo file

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

save and exit esc

:wq

④Install Nginx

yum install -y nginx
# yum install nginx
# 如果使用yum install xxxx,会找到安装包之后,询问你Is this OK[y/d/N],需要你手动进行选择。
# 但是如果加上参数-y,就会自动选择y,不需要你再手动选择!

⑤ Check the version number of Nginx

nginx -v
# 显示nginx的版本号和编译信息

⑥View all Nginx packages installed

yum list | grep nginx

⑦ View the file location information related to Nginx installation

whereis nginx

Nginx directory structure

# Nginx终端管理理命令
/usr/sbin/
# 启动 Nginx
/usr/sbin/nginx

# Nginx 配置
/etc/nginx
/etc/nginx/nginx.conf
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf

# Nginx模块⽬录
/usr/lib64/nginx

# 默认站点目录
/usr/share/nginx

4. Nginx static website deployment

①Directly enter the static file directory of Nginx's default site  /usr/share/nginx/html and upload your own project files to complete the basic test deployment, as the first experience of Nginx deployment

# 查看nginx的文件位置
whereis nginx
# 进入nginx 默认站点静态文件目录
cd /usr/share/nginx/
ll
cd html
ll

② Login link Xftp

 ③Upload project source files

④ After uploading the source file of the website, enter the server ip in the browser to access!

Guess you like

Origin blog.csdn.net/G_ing/article/details/128706809