准备

  • 域名
  • 服务器
  • SSH 客户端 (Xshell)
  • FTP 客户端 (FileZilla)

开始

1. 远程连接至服务器

Xshell 1

Xshell 2

2. 更新系统

以 debian 10 为例

apt update      // 更新软件包版本数据库
apt dist-upgrade -y     // 更新所有可升级软件

3. 使用 oneinstack 套件快速部署环境

oneinstack

由于我的网站是纯静态网站,所以只需安装 Nginx 和 FTP 服务

4. 添加域名解析记录

DNS

5. 创建虚拟主机 vhost

root@iZj6c4r627vc7uaugviqojZ:~/oneinstack# ./vhost.sh 

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. Use HTTP Only # 仅使用 HTTP 
	2. Use your own SSL Certificate and Key # 使用自己的证书和密钥
	3. Use Let's Encrypt to Create SSL Certificate and Key # 使用 Let's Encrypt 创建证书和密钥
	q. Exit
Please input the correct option: 3 # 因上一步已经将域名解析设定好,所以选择 3

Please input domain(example: www.example.com): gentrabbit.moe # 填写自己的域名
domain=gentrabbit.moe

Please input the directory for the domain:gentrabbit.moe : # 网站目录,默认即可
(Default directory: /data/wwwroot/gentrabbit.moe): 
Virtual Host Directory=/data/wwwroot/gentrabbit.moe

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: y # 是否添加子域名

Type domainname or IP(example: example.com other.example.com): www.gentrabbit.moe # 添加 www 子域名
domain list=www.gentrabbit.moe

Do you want to redirect from www.gentrabbit.moe to gentrabbit.moe? [y/n]: y # 是否将 www 子域名重定向至主域名

Do you want to redirect all HTTP requests to HTTPS? [y/n]: y # 是否将 HTTP 重定向至 HTTPS

...
[Mon 31 May 2021 11:30:54 PM CST] Your cert is in  /root/.acme.sh/gentrabbit.moe/gentrabbit.moe.cer 
[Mon 31 May 2021 11:30:54 PM CST] Your cert key is in  /root/.acme.sh/gentrabbit.moe/gentrabbit.moe.key 
[Mon 31 May 2021 11:30:54 PM CST] The intermediate CA cert is in  /root/.acme.sh/gentrabbit.moe/ca.cer 
[Mon 31 May 2021 11:30:54 PM CST] And the full chain certs is there:  /root/.acme.sh/gentrabbit.moe/fullchain.cer 

Do you want to add hotlink protection? [y/n]: n # 是否开启防盗链

Allow Rewrite rule? [y/n]: n # 是否启用重写规则 (静态网站不需要)

Allow Nginx/Tengine/OpenResty access_log? [y/n]: y # 开启日志
You access log file=/data/wwwlogs/gentrabbit.moe_nginx.log

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  gentrabbit.moe
Virtualhost conf:             /usr/local/nginx/conf/vhost/gentrabbit.moe.conf
Directory of:                 /data/wwwroot/gentrabbit.moe
Let's Encrypt SSL Certificate:/usr/local/nginx/conf/ssl/gentrabbit.moe.crt
SSL Private Key:              /usr/local/nginx/conf/ssl/gentrabbit.moe.key

6. 创建 FTP 用户

root@iZj6c4r627vc7uaugviqojZ:~/oneinstack# ./pureftpd_vhost.sh 

#######################################################################
#       OneinStack for CentOS/RedHat 7+ Debian 8+ and Ubuntu 16+      #
#                 FTP virtual user account management                 #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
	1. UserAdd # 添加用户
	2. UserMod # 编辑用户
	3. UserPasswd # 修改密码
	4. UserDel # 删除用户
	5. ListAllUser # 列出所有用户
	6. ShowUser # 显示某个用户信息
	q. Exit # 退出
Please input the correct option: 1 # 添加用户

Please input a username: ****** # 用户名

Please input the password: ****** # 密码

Please input the directory(Default directory: /data/wwwroot): /data/wwwroot/gentrabbit.moe # 网站目录 (复制第 5 步中的 Directory of 信息)
Password: 
Enter it again: 
#####################################

[******] create successful! 

You user name is : ******
You Password is : ******
You directory is : /data/wwwroot/gentrabbit.moe


What Are You Doing?
	1. UserAdd
	2. UserMod
	3. UserPasswd
	4. UserDel
	5. ListAllUser
	6. ShowUser
	q. Exit
Please input the correct option: q # 退出

7. 连接 FTP 上传网站文件

FTP