Cloud Hosting Tutorial: Lightweight Application Server Experience

Many students want to set up their own cloud services, which is inseparable from the cloud server.

Now there is a new cloud host called "lightweight application server", which is very suitable for newcomers. This article introduces its basic situation, demonstrates its usage, and helps you get started easily.

What I used for demonstration is Lighthouse, Tencent Cloud's lightweight application server . My own server is in Tencent Cloud, and I am familiar with it, and I know my classmates there.

Tencent Cloud recently held Techo Day, a technology open day. The slogan is "simplify the complexity and make it easy to use". It happens that there are relevant materials, which match the theme of this article. I asked them if they were coming, and put it at the end of the article.

1. Introduction

First, let me explain what a lightweight application server is and how it relates to cloud hosting.

As we all know, compared with traditional virtual hosts, the biggest feature of cloud hosts is that they can be scaled in real time, can be expanded and contracted arbitrarily, and have no resource restrictions.

In order to do this, each of its parameters is individually configured and charged separately: CPU, memory, hard disk, bandwidth, IP address, snapshot, security policy...

The picture below is the purchase page of Tencent Cloud's cloud server CVM . Let's see how many types are available, and this is only a part.

Although so many configuration items are very flexible, it is a bit too complicated for novices. Sometimes, we just want to build a simple personal website, or have a server environment for learning and testing. It is best to use it out of the box without so many adjustable configurations.

Aware of this problem, cloud service providers designed a simplified version of the cloud server, which is a lightweight application server.

2. What is a lightweight application server

Simply put, a lightweight application server is a repackaging of the underlying resources of the cloud server, trying to hide the complexity as much as possible, making it easy to use and friendly to novices.

It has the following characteristics.

(1) Package purchase. All configuration items are bundled into a package, as long as you select a package, all kinds of resources will be configured for you. The following are all the current packages of Tencent Cloud.

It can be seen that the amount given is relatively sufficient. The smallest package also has two cores, 2GB memory, 4Mbps bandwidth, and 300GB traffic, which is completely enough for small websites.

(2) Out of the box. When installing the system, it provides images of many common applications, one-click installation, and direct use. See the examples below for details.

(3) Full function. Most of the things that cloud servers can do can be done by lightweight application servers, such as using cloud databases, COS storage, security protection, etc. There are only a few tasks with high calculation volume, high read and write, and cluster requirements, which are not suitable for it, so its playability is not bad.

(4) The price is cheaper . It is much cheaper than the cloud server with the same configuration. During the big promotion, the cheapest package is only a few tens of yuan a year. At such a price, you can experience a full-featured cloud host, which is still very cost-effective.

In short, the design concept of a lightweight application server is simple, easy to use, and lightweight. It uses the same underlying resources as the cloud server, such as CPU, memory, and hard disk. There is no difference in performance and usage. The difference is mainly reflected in the product form presented to users. It is more like a traditional virtual host, but its functionality, stability, and security are far superior to that of a virtual host.

3. The purpose of lightweight application server

As a full-featured server, you can install any software you want on the lightweight application server.

In general, it has the following three applicable scenarios.

(1) Small-scale services with light loads , such as corporate official websites/personal blogs/forum communities/e-commerce websites, etc., can also place WeChat applets/mini-game backend services.

(2) Personal tools , such as cloud disk, picture bed, Docker, etc.

(3) Cloud development/testing/learning environment .

4. Open the server

Next, let's demonstrate how to open a lightweight application server.

4.1 Purchase process

Log in to the lightweight application server console and enter the purchase page.

First, select the location of the computer room.

然后,选择一个镜像。所谓镜像,就是服务器的安装模板。为了演示,我选择"宝塔 Linux 面板"。

注意,同一页面也有 Windows 服务器,这个教程要选择 Linux。

最后,选择套餐,最便宜的就可以了。付款就马上开通了。

4.2 SSH 登录

开通以后的第一件事,就是完成 SSH 登录设置,这样才能登录服务器。

第一步,进入控制台,选择左侧的"密钥"菜单,点击"创建密钥"按钮。

第二步,弹出对话框里面,可以选择"创建新密钥对"生成新的密钥,也可以上传已有的公钥(注意,不要上传私钥)。

第三步,将上一步得到的密钥与主机绑定。绑定密钥需要关机操作,所以先在设置页上,点击"关机"按钮。

等到关机后,进入主机的详细设置,点击"管理密钥对"。

然后,点击"绑定密钥对",将密钥与主机绑定。

第四步,绑定成功后,重新开机。

这时,在本地计算机的命令行下,键入下面的命令。

$ ssh[email protected][服务器的 IP 地址]

成功登录后,然后就可以对主机进行各种命令行操作了。不熟悉 SSH 的同学,可以参考这篇教程

注意,这时我们是根用户身份,最好登录后,在服务器上创建一个普通用户,以后都用普通用户登录,并禁止根用户登录。详细的操作可以参考我写的《Linux 服务器的初步配置流程》

4.3 宝塔面板

前面安装时,选择的是宝塔面板镜像。它是一个管理工具,通过 Web 界面,对主机进行管理。下面看看怎么使用它。

它的访问端口是8888,这个端口默认是不开放的,必须先对外开放。方法是进入主机的"防火墙"设置页,点击"添加规则"。

新规则的内容就是,允许服务器对外暴露 TCP 协议的 8888 端口。

添加规则成功后,你打开浏览器,访问http://[主机 IP 地址]:8888,就能看到提示页。

宝塔面板默认开启了安全入口,这时是进不去的。登录的具体方法,可以参考官方文档

五、应用安装

登录服务器后,就可以自行在命令行下安装各种应用。

为了简化操作,对于一些常见的应用,官方提供了"一键安装"。你可以在购买时指定要安装的应用镜像,也可以对现有的服务器重装系统(会删除现有数据)。

这里以安装 WordPress 镜像为例。

选中 WordPress 镜像,点击"确定"后,安装很快就能完成。接着,访问服务器的 IP 地址,应该就可以看到下面的页面了。

这表明 WordPress 已经可以正常使用了,它的登录密码见主机后台的"应用管理"页。

注意,WordPress 的数据库,是随同镜像一起安装在服务器上面的。如果数据比较重要,或者多台主机使用一个数据库,我建议额外购买专门的云数据库服务。

除了 WordPress,其他官方镜像的安装方法也大同小异。比如,选择个人网盘 Cloudreve 的镜像,安装后就会得到下面的页面。

六、Docker 应用安装

最后演示在轻量应用服务器上,安装 Docker 镜像,毕竟大部分复杂应用现在都提供 Docker 镜像安装方式。

这时,服务器需要先安装docker应用程序。为了便于演示,我选择将系统重装为 docker CE 镜像,这样比较简单。

注意,每次重装系统后,都需要把 SSH 密钥和服务器重新绑定。绑定成功后,使用下面的命令登录服务器。

$ ssh[email protected][主机 IP 地址]

登录进去后,docker 应该已经安装好了,可以执行下面的命令试试看。

# docker -v

上面命令中,前面的命令提示符#表示当前是根用户环境。

下面以安装 Fathom 的 Docker 镜像为例,它是一个比较简单的网站访问统计工具。

# docker run -d -p 80:8080 usefathom/fathom:latest

只要运行上面一行命令就可以了,正常情况下,执行完这条命令,Fathom 服务就已经安装完成,并在后台运行了。

这时,浏览器访问主机的 IP 地址,就可以看到 Fathom 的页面了。

此外,你还可以安装 Gitea 的镜像,作为自己的代码托管服务器,操作跟上面基本一样,可以参考这篇文章

有些复杂的 Docker 镜像,还需要安装 Docker Compose,这里就不演示了,可以参考我写的《Docker 入门教程》《Docker 微服务教程》

七、结束语

轻量应用服务器总体上是一种比较简单的云服务,容易上手,性价比高,适合个人用户和中小企业。如果你刚刚接触云开发,想尝试自己的第一台云服务器,不妨从轻量应用服务器开始。

本文开头提到了,腾讯云最近有一个 Techo Day 技术开放日活动。活动正好有实践课程,分享了如何通过轻量应用服务器 Lighthouse 搭配应用镜像,一步步快速构建自己的云端硬盘。

腾讯官方把这些资料、课件、以及其他轻量级云服务器产品的介绍,整理成了一份轻量级工具指南。我把这份资料要来了,感兴趣的朋友可以手机打开这个链接,或者微信扫码,从腾讯云下载。

(完)

Guess you like

Origin blog.csdn.net/ruanyf/article/details/126706084