Experience introduction
Scenario Describes setting up a Zblog using a functional computing service. The Serverless Devs command-line tool enables one-click deployment of many frameworks, applications, and cases to a functional computing platform.
Alibaba Yunyunqi Experience Lab offers 2 hours of ECS server – free to experience in a real cloud environment, click here
Background knowledge
This scenario involves the following cloud products and services:
FunctionCompute
Function computing is an event-driven, fully managed computing service. With function computing, you don’t need to purchase and manage infrastructure like servers, you just need to write and upload code. Function computing prepares you for computing resources, runs tasks flexibly and reliably, and provides functions such as log querying, performance monitoring, and alerting. Function computing helps you build applications quickly by focusing on function code without having to manage a server. Function calculations scale flexibly, and you only have to pay per usage.
Function computing Serverless services have the following advantages over self-built services:
Simple to start, only focus on business logic development, greatly improve the efficiency of engineering development.
The self-built solution has a lot of learning and configuration costs. For example, ESS needs to configure various parameters in different scenarios, and the maintenance and upgrade of the system environment are troublesome.
O&m free, function execution level granularity monitoring and alarm.
Millisecond elastic capacity expansion ensures elastic high availability and covers latency-sensitive and cost-sensitive types.
File Storage NAS
The file storage NAS is a cloud-based distributed file system with high performance that can be widely shared and scalable. Supports intelligent layering of hot and cold data, effectively reducing data storage costs. Widely used in enterprise-level application data sharing, containers, AI machine learning, Web services and content management, application development and testing, media and entertainment workflows, database backup and other scenarios.
Serverless Devs Developer tools
Serverless Devs is a componentized and pluginized Serverless developer platform, where developers can pluggable different Serverless services and frameworks, and participate in the development of components and plug-ins. Serverless Devs supports both industrial-grade Serverless services and various open source Serverless frameworks. Without having to study and learn every Serverless tool on the market, developers can easily and quickly “get started” with mainstream Serverless services and frameworks with Serverless Devs.
Enable the function computing service
Use your own Ali Cloud account to log in ali Cloud console, and then enter the function calculation details page.If the following page is displayed, the service is successfully opened.
Install the Serverless Devs command-line tool
Install the Node.js environment.
Run the following command to download the node.js installation package.
Wget HTTP: / / https://npm.taobao.org/mirrors/node/v12.4.0/node-v12.4.0-linux-x64.tar.xzCopy the code
Run the following command to decompress the installation package and rename it.
Tar -xvf node-v12.4.0-linux-x64.tar.xz && mv node-v12.4.0-linux-x64 //usr/local/nodeCopy the code
Run the following command to configure environment variables.
echo "export PATH=$PATH:/usr/local/node/bin" >> /etc/profile
source /etc/profile
Copy the code
Run the following command to install the serverless-devs tool.
npm install @serverless-devs/s -g
Copy the code
If the following information is displayed, the installation is complete.
Note: If the installation process is slow, you can use taobao NPM source, installation command is NPM –registry=registry.npm.taobao.orgInstall @ serverless – devs/s – g.
Run the following command to view the version and check whether the installation is correct:
s -v
Copy the code
The result is as follows, and you can see the version of the Serverless-devs tool.
Configure aliyun account information
Description:
In this scenario, a free ECS server is provided, but the function computing service is enabled under your account. In the following configuration information, you need to configure the UID, AK ID, and AK Secret information of your account.
Run the following command to configure the account information:
s config add
Copy the code
Then fill in the following information as prompted.
Cloud vendor: Alibaba.AccountID: please check your aliyun primary AccountID on the account security Settings page.
AccessKeyID and AccessKeySecret: Check the AccessKeyID and AccessKeySecret of your account on the security information management page.
If you use the main account of Aliyun, click in the dialog box displayed on the security information management page to continue using the AccessKey.If you are using aliYun RAM subuser, you need to ensure that your subuser has function computing management rights AliyunFCFullAccess, see Authorizing a RAM User.
The following figure shows your AccessKey ID and AccessKey Secret. If your account has not used an AccessKey, click in the upper right corner to create an AccessKey.After the configuration is successful, information similar to the following is displayed:
Set up Zblog blog project
Run the following command to initialize a Zblog project at the current path.
s init devsapp/start-zblog
Copy the code
Run the following command to enter the project name start-zblog.
start-zblog
Copy the code
3. Select the default credentials and press Enter.
If the following output is displayed, the initialization is complete.
4. Run the following command to go to the start-zblog directory.
cd start-zblog
Copy the code
5. Run the following command to deploy the Zblog project.
s deploy
Copy the code
A. Select yes and press Enter.Copy the code
B. Select Yes and press Enter.Copy the code
C. Select Yes and press Enter.
If the following result is returned, the installation of the Zblog project is deployed and the URL is copied.
6. Open the FireFox ESR browser on the virtual desktop, paste the URL, and access it. On the Installation Protocol page, select I have read and agree to this agreement, and click Next.
7. On the environment check page, click Next.
8. On the database setup and Setting page, select SQLite as the database type, enter the website title, administrator name, administrator password, and confirm password, and click Next.
Parameter description:
Database type: Select SQLite. Site title: Custom site title, myblog in this example. Administrator name: User-defined administrator name. In this example, the name is admin. Administrator password: user-defined administrator password. Confirm Password: Enter the administrator password again.9. On the installation result page, click finish.10. On the home page, click Log In background.
11. On the login page, enter the user name and password, and click.12. In the navigation bar on the left of the background page, click New article.
13. On the edit page, enter the title and body, and click Submit.
14. If the following page is displayed, the article is published successfully. On the navigation bar of the article management page, click return.
You can see the new articles you just published on the home page.