最近我弟弟在学网页设计,看到他的成品之后我问了一句,你知道怎样把你设计的网页发布到互联网上吗?
他表示一脸懵逼,我心里不禁暗想,得亏你们考试不考这个。不过借此机会,给大家介绍一下如何免费申请一台属于自己的服务器,并将自己的网站部署上去供公网用户使用。
这里需要用到的是亚马逊云科技提供的Lightsail
服务器
废话不多说,开始。
1 创建服务器
首先打开该网站:
https://aws.amazon.com/cn/lightsail/?nc2=type_a
如果你之前有过账号,就不需要重新注册了,免费使用三个月的活动是老用户也可以享受的,如果你是新用户,则可以进行注册。
注册亚马逊云科技
:https://aws.amazon.com/cn/free/?sc_channel=seo&sc_campaign=blog1118
根据提示,继续下面的几步。
进入控制台之后,点击创建实例:
区域建议选东京,选择centos7
系统。
然后新建一个密钥对:
生成之后别忘了下载密钥对
。
之后就可以选择具体实例了,这三个都是免费三个月的。
一切准备就绪之后,点击创建,等待几秒就可以看到创建的实例了。
2 连接服务器
有两种方式,一种是在线连接,直接点击终端按钮即可:
还有一种,是在本地通过密钥连接,这里以Royal TSX
为例介绍。
选择下载的密钥文件:
注意连接的时候要用centos
登录:
3 服务器评测
接下来评测一下服务器的性能:
wget -N --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh sudo bash superbench.sh
感觉还是很不错的:
[centos@ip-172-26-2-242 ~]$ sudo bash superbench.sh
=========================================================
\ Superbench.sh Script /
\ Basic system info, I/O test and speedtest /
\ v1.1.7 (7 Apr 2020) /
\ Created by Oldking /
=========================================================
Intro: https://www.oldking.net/350.html
Copyright (C) 2020 Oldking oooldking@gmail.com
Installing Speedtest-cli ...
Installing tools.py ...
Installing Fast.com-cli ...
----------------------------------------------------------------------
Superbench.sh -- https://www.oldking.net/350.html
Mode : Standard Version : 1.1.7
Usage : wget -qO- sb.oldking.net | bash
----------------------------------------------------------------------
CPU Model : Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz
CPU Cores : 2 Cores 2499.998 MHz x86_64
CPU Cache : 36608 KB
OS : CentOS 7.9.2009 (64 Bit) KVM
Kernel : 3.10.0-1160.15.2.el7.x86_64
Total Space : 5.4 GB / 60.0 GB
Total RAM : 635 MB / 1799 MB (1042 MB Buff)
Total SWAP : 4 MB / 1024 MB
Uptime : 0 days 0 hour 43 min
Load Average : 0.04, 0.09, 0.25
TCP CC : cubic
ASN & ISP : AS16509, Amazon Technologies Inc.
Organization : AWS EC2 (ap-northeast-1)
Location : Tokyo, Japan / JP
Region : Tokyo
----------------------------------------------------------------------
I/O Speed( 1.0GB ) : 77.9 MB/s
I/O Speed( 1.0GB ) : 110 MB/s
I/O Speed( 1.0GB ) : 136 MB/s
Average I/O Speed : 108.0 MB/s
----------------------------------------------------------------------
Node Name Upload Speed Download Speed Latency
Speedtest.net 945.90 Mbit/s 4265.03 Mbit/s 1.56 ms
Fast.com 0.00 Mbit/s 71.1 Mbit/s -
Nanjing 5G CT 267.50 Mbit/s 1556.86 Mbit/s 36.61 ms
Hefei 5G CT 803.51 Mbit/s 2409.70 Mbit/s 39.56 ms
Shanghai 5G CU 1333.87 Mbit/s 2886.24 Mbit/s 55.06 ms
----------------------------------------------------------------------
Finished in : 2 min 48 sec
Timestamp : 2023-11-17 10:55:14 GMT+8
Results : ./superbench.log
----------------------------------------------------------------------
Share result:
· https://www.speedtest.net/result/c/94fc654b-8ba3-4fdf-ab47-61c7a6399c4f
· https://paste.ubuntu.com/p/kYK5kfvjn4/
----------------------------------------------------------------------
速度很快
4 安装宝塔
服务器准备之后,安装宝塔,这个比较简单,一条命令即可。
sudo yum install -y wget && wget -O install.sh https://download.bt.cn/install/install_6.0.sh && sudo sh install.sh ed8484bec
[centos@ip-172 ~]$ sudo yum install -y wget && wget -O install.sh https://download.bt.cn/install/install_6.0.sh && sudo sh install.sh ed8484bec
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: download.cf.centos.org
* extras: download.cf.centos.org
* updates: download.cf.centos.org
软件包 wget-1.14-18.el7_6.1.x86_64 已安装并且是最新版本
无须任何处理
--2023-11-17 02:19:58-- https://download.bt.cn/install/install_6.0.sh
正在解析主机 download.bt.cn (download.bt.cn)... 124.226.64.155
正在连接 download.bt.cn (download.bt.cn)|124.226.64.155|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:34763 (34K) [application/octet-stream]
正在保存至: “install.sh”
100%[============================================================================================================================>] 34,763 --.-K/s 用时 0s
2023-11-17 02:19:58 (319 MB/s) - 已保存 “install.sh” [34763/34763])
+----------------------------------------------------------------------
| Bt-WebPanel FOR CentOS/Ubuntu/Debian
+----------------------------------------------------------------------
| Copyright © 2015-2099 BT-SOFT(http://www.bt.cn) All rights reserved.
+----------------------------------------------------------------------
| The WebPanel URL will be http://SERVER_IP:8888 when installed.
+----------------------------------------------------------------------
| 为了您的正常使用,请确保使用全新或纯净的系统安装宝塔面板,不支持已部署项目/环境的系统安装
+----------------------------------------------------------------------
Do you want to install Bt-Panel to the /www directory now?(y/n):y
---
---
---
Running transaction
Installing : ebtables-2.0.10-16.el7.x86_64 1/8
Installing : ipset-libs-7.1-1.el7.x86_64 2/8
Installing : ipset-7.1-1.el7.x86_64 3/8
Installing : python-slip-0.4.0-4.el7.noarch 4/8
Installing : python-slip-dbus-0.4.0-4.el7.noarch 5/8
Installing : python-firewall-0.6.3-13.el7_9.noarch 6/8
Installing : firewalld-filesystem-0.6.3-13.el7_9.noarch 7/8
Installing : firewalld-0.6.3-13.el7_9.noarch 8/8
Verifying : ipset-7.1-1.el7.x86_64 1/8
Verifying : python-slip-dbus-0.4.0-4.el7.noarch 2/8
Verifying : firewalld-filesystem-0.6.3-13.el7_9.noarch 3/8
Verifying : firewalld-0.6.3-13.el7_9.noarch 4/8
Verifying : python-slip-0.4.0-4.el7.noarch 5/8
Verifying : python-firewall-0.6.3-13.el7_9.noarch 6/8
Verifying : ipset-libs-7.1-1.el7.x86_64 7/8
Verifying : ebtables-2.0.10-16.el7.x86_64 8/8
Installed:
firewalld.noarch 0:0.6.3-13.el7_9
Dependency Installed:
ebtables.x86_64 0:2.0.10-16.el7 firewalld-filesystem.noarch 0:0.6.3-13.el7_9 ipset.x86_64 0:7.1-1.el7 ipset-libs.x86_64 0:7.1-1.el7
python-firewall.noarch 0:0.6.3-13.el7_9 python-slip.noarch 0:0.4.0-4.el7 python-slip-dbus.noarch 0:0.4.0-4.el7
Complete!
success
==================================================================
Congratulations! Installed successfully!
========================面板账户登录信息==========================
外网面板地址: http://13.xxxxx:20071/c58adff5
内网面板地址: http://172.xxxxx:20071/c58adff5
username: xxxx
password: xxxx
=========================打开面板前请看===========================
【云服务器】请在安全组放行 20071 端口
因默认启用自签证书https加密访问,浏览器将提示不安全
点击【高级】-【继续访问】或【接受风险并继续】访问
教程:https://www.bt.cn/bbs/thread-117246-1-1.html
==================================================================
Time consumed: 1 Minute!
[centos@ip-172-26-2-242 ~]$
接下来是放行端口:
添加之后,登录宝塔,选择极速安装:
等待几分钟安装完成。
安装完成之后,添加站点:
如果没买域名的话,就直接写IP:端口
,例如:
创建完成之后,把你做好的网页上传到刚刚创建的目录中即可,把名字改为index.html
这时浏览器输入:ip:6789
,就可以看到你上传的网页了~~