当前位置:网站首页>Scenario practice: quickly build wordpress blog system based on function calculation
Scenario practice: quickly build wordpress blog system based on function calculation
2022-07-07 01:44:00 【Choice~】
Function calculation tutorial
Alibaba cloud's function calculation ——FC , It's an event driven full hosting Serverless Computing services , Developers don't need to manage infrastructure like servers , Just write code and upload . Function calculation FC Computing resources will be ready for you , And with elasticity 、 Run your code in a reliable way .
Receive evaluation products
Opening service
Prerequisite
You have successfully registered your Alibaba cloud account , And complete real name certification . Specific information , Please see the Alicloud account registration process .
Operation steps
Enter the function calculation homepage .
single click Administrative console .
stay overview page , single click Free to open .
On the opening instructions panel , Read carefully and select Function computing service protocol Check box , single click Open now , And then click close , Enter the function calculation console .
Optional :
On the left navigation bar , single click overview , stay Cloud resource access authorization Dialog box , single click Agree to authorize Grant your account AliyunFCDefaultRole role .
Authorized success
Successful authorization means that function computing has access to cloud resources .
privilege grant failed
Alicloud account
It may be caused by some functions that cannot be authorized . But function calculation can still be used normally . If you still need to grant the system default role , please Submit work order consulting .
RAM user
When your authorization fails, you need to judge whether your account has authorization ability .
- without RAM jurisdiction , You need to log in through Alibaba cloud account Function calculation console , Then perform the authorization operation . After successful authorization , You pass RAM The user logs in again Function calculation console You will no longer be prompted to authorize .
- If already RAM Authorization still failed , It may be caused by some functions that cannot be authorized . But function calculation can still be used normally . If you still need to grant the system default role , please Submit work order consulting .
Details about permission management , Please see the Rights management .
Use the console to create functions
This article introduces how to quickly develop a simple Serverless Hello World application .
Prerequisite
Background information
Function calculation provides you with a simple Hello World Example , You can create services and functions directly in the function calculation console , After successful creation, you can test the function immediately to see the details of function execution , For example, return the result 、 Executive summary and log output .
This article takes the method of creating from scratch as an example , Describes how to create functions .
Usage flow
The process is described as follows :
- Create services .
- Create a function , Write code , Deploy the application into the function .
- Trigger function .
- Check the execution log .
- View service monitoring .
Operation steps
Create services .
Sign in Function calculation console .
On the left navigation bar , single click Services and functions .
In the top menu bar , Choose the region .
stay List of services page , single click Create services .
stay Create services panel , Fill in the service name and description , And then click determine .
You can also visit Create services panel , Set whether to enable Alibaba cloud log service and Alibaba cloud link tracking . Details , Please see the management service .
After you successfully create the service , The page will jump to the service page Function management page .
Create a function .
stay Management functions page , single click Create a function .
stay Create a function page , choice Use standards Runtime Create from scratch .
The basic settings are as follows :
Parameters If required operation Example value The name of the function no Fill in the custom function name . Must start with a letter , Can contain numbers 、 Letter ( Case sensitive )、 Underline (_) Underline (-), No more than 64 Characters . explain If you do not fill in the name , Function calculation will be automatically created for you . Function Container mirror yes single click choice ACR Container image in , In the pop-up Select container mirror Dialog box , Select the created Container image instance and ACR Mirror warehouse , Then select the image area below to find the target image and on its right operation Column click choice . test-registry-vpc.cn-chengdu.cr.aliyuncs.com/test/registry:latest Listening port yes In the container image HTTP Server Listening port . The default port is 9000. 9000 Command no Start command for container , The format is [“python”,“server.py”]. If not , By default, the Entrypoint/CMD. [“/code/myserver”] Args no Start parameters of the container , The format is [“–port”,“9000”]. If not , By default, the CMD. [“-arg1”, “value1”] Function trigger mode yes Select function trigger method . Triggered by an event : Trigger function execution through timers and triggers of other Alibaba cloud services . adopt HTTP Request trigger : By sending HTTP Request trigger function execution , Suitable for rapid construction Web Service and other scenarios . Triggered by an event Instance type yes Choose the type of instance that suits you . Elastic examples Performance examples GPU example ( In the public test ) For more information , Please see the Instance type and usage mode . Billing details for various instance types , Please see the Billing Overview . explain If you want to use GPU example , please Submit work order apply . Specific operation , Please see the Instance type . Elastic examples Memory specifications yes Set the function execution memory . Select input : Select the required memory from the drop-down list . Manual input : single click Enter the memory size manually , Customizable function execution memory . The memory specifications are as follows : Elastic examples : Value range [128, 3072], Unit is MB. Performance examples : Value range [4, 32], Unit is GB.GPU example : Value range [16, 32], Unit is GB. explain The memory entered must be 64 MB Multiple . 512 MB GPU Video memory specifications yes Instance type choice GPU example Required when . 8 G stay Basic settings Area , Set related parameters , And then click establish .
The parameter configuration is as follows :
** Optional :** The name of the function : The name of the custom function is Function.
Running environment : choice Node.js 12.
Request handler type : choice Handle event requests .
Instance type : choice Elastic examples .
Memory specifications : Set the function execution memory to 512 MB.
Instance concurrency : Set to 1.
Request handler : Set to index.handler
When you successfully create the function , The page will jump to the function details page function code Tab .
Execute function .
On the objective function details page function code Tab , single click Test functions .
explain You can also edit your code in the code editor , Realize secondary development .
After execution , You can go to function code Tab to view the execution results and detailed log information .
Create functions in the console
In this paper, in /tmp Directory as an example , Describes how to create functions , Suppose the region of function calculation is South China 1( Shenzhen ), Image warehouse name nodejs-express.
Push your function image to the default instance image warehouse .
Execute the following command to enter /tmp Catalog .
cd /tmp
stay /tmp Execute the following command in the directory to clone the sample project .
git clone https://github.com/awesome-fc/custom-container-docs.git
Execute the following command , Enter project directory .
cd custom-container-docs/nodejs-express
Execute the following command to specify the image warehouse .
export IMAGE_NAME="registry.cn-shenzhen.aliyuncs.com/fc-demo/nodejs-express:v0.2"
Execute the following command to package the image .
docker build -t $IMAGE_NAME .
explain For carrying Apple Chip Mac The computer ( Or others ARM The machine of Architecture ), When building an image, you need to specify that the compilation platform of the image is Linux/Amd64. Realize cross platform compilation , Example code such as
docker build --platform linux/amd64 -t $IMAGE_NAME .
.Execute the following command to push the image .
docker push $IMAGE_NAME
Introduction to the experience
This scenario describes how to use the function computing service to build a Wordpress Blog . Use Serverless Devs Command line tools can integrate many frameworks 、 application 、 The case is deployed to the function computing platform with one click .
Click to obtain the required cloud product resources
Background knowledge
This scenario describes how to use the function computing service to build a Wordpress Blog . Use Serverless Devs Command line tools can integrate many frameworks 、 application 、 The case is deployed to the function computing platform with one click .
This scenario mainly involves the following cloud products and services :
Function calculation (FunctionCompute)
Function computing is an event driven fully managed computing service . Use functions to calculate , You don't need to purchase and manage infrastructure like servers , Just write and upload the code . Function calculation is ready for you to calculate resources , Run tasks flexibly and reliably , And provide log query 、 Performance monitoring, alarm and other functions . Function calculations help you avoid managing servers (Serverless), Just focusing on function code can quickly build applications . Function computation can scale elastically , You just have to pay by usage .
Function calculation Serverless Compared with self built service, service has the following advantages :
Easy to get started , Focus on business logic development only , Greatly improve the efficiency of engineering development .
There are too many learning and configuration costs for self built programs , For example, for different scenarios ,ESS Various parameter configurations are required, and the maintenance and upgrading of the system environment are troublesome .
No operation and maintenance , Function execution level granularity monitoring and alarm .
Millisecond elastic expansion , Ensure high flexibility , It can also cover delay sensitive and cost sensitive types .
Serverless Devs Developer tools
Serverless Devs It is a component and plug-in Serverless Developer Platform , Developers can use different pluggable devices in the platform Serverless Services and frameworks for , Participate in the development of components and plug-ins at the same time . Whether it's industrial grade Serverless service , Or all kinds of open source Serverless frame ,Serverless Devs Can be friendly and supportive . Developers don't have to deal with every model on the market Serverless Tools for research and learning , Just pass Serverless Devs, It can be simple 、 shortcut “ Get started ” Main stream Serverless Services and frameworks .
install Serverless Devs Command line tools
install Node.js Environmental Science .
Execute the following command , download Node.js Installation package .
wget https://npm.taobao.org/mirrors/node/v12.4.0/node-v12.4.0-linux-x64.tar.xz
Execute the following command , Unzip the installation package and rename .
tar -xvf node-v12.4.0-linux-x64.tar.xz && mv node-v12.4.0-linux-x64/ /usr/local/node
Execute the following command , Configure environment variables .
echo "export PATH=$PATH:/usr/local/node/bin" >> /etc/profile
source /etc/profile
Execute the following command , install Serverless-Devs Tools .
npm install @serverless-devs/s -g
The results are as follows , Indicates installation is complete .
** explain :** If the installation process is slow , You can use Taobao npm Source , The installation command is
npm --registry=https://registry.npm.taobao.org install @serverless-devs/s -g.
Execute the following command , Check the version and check that it is installed correctly .
s -v
The results are as follows , You can see Serverless-Devs Version of the tool .
Configure alicloud account information
This scenario provides free ECS The server , However, the function calculation service used is opened under your account , The following configuration information is also required AK ID and AK Secret Information .
Execute the following command , Configure account information .
s config add
Then fill in the following information according to the prompts .
- Cloud manufacturers : Choose alicloud (alibaba).
- AccessKeyID and AccessKeySecret: Please check your account number on the security information management page AccessKey ID and AccessKey Secret.
- If you are using alicloud RAM Sub user , You need to make sure that your child users have function calculation management rights AliyunFCFullAccess, See for RAM User authorization .
Here is your AccessKey ID and AccessKey Secret. If your account has not been used AccessKey, Please click in the upper right corner to create AccessKey.
After the configuration is successful, the display is similar to the following .
build Wordpress Blog project
- Execute the following command , Initialize a... In the current path wordpress project .
s init devsapp/start-wordpress
- Execute the following command , Execute and enter the project name start-zblog.
start-wordpress
Select the region where the app is created and press enter .
explain :
It is recommended that you select the region where the application is created as ECS ECS Region of the instance , You can view ECS in the cloud product resource list ECS Region of the instance .
- Execute the following command , Execute input service name web-framework.
web-framework
- Execute the following command , Execute input function name wordpress.
wordpress
Select the default credentials and press enter .
The results are as follows , Indicates that initialization is complete .
- Execute the following command , Get into start-wordpress Catalog .
cd start-wordpress
Execute the following command , Deploy wordpress project .
s deploy
Input Y Press enter , Select auto create NAS.
The results are as follows , Said the installation wordpress Project deployment completed , And copy domain.
Open the virtual desktop FireFox ESR browser , Paste and access domain. Enter the site title in sequence 、 user name 、 Password and email , click setup WordPress.
Parameter description :
Site title : Custom title .
user name : Custom user name .
password : Input password .
mailbox : Enter email .
- On the success page , Click login .
stay WordPress The login page , Enter your username and password , Click login .
The following interface appears , Indicates that you have successfully logged in wordpress Blog background management .
边栏推荐
- Start from the bottom structure to learn the customization and testing of fpga---- FIFO IP
- AcWing 345. Cattle station solution (nature and multiplication of Floyd)
- IDEA常用的快捷键
- 【芯片方案设计】脉搏血氧仪
- How to manage distributed teams?
- The cradle of eternity
- MySQL最基本的SELECT(查询)语句
- Use nodejs to determine which projects are packaged + released
- AcWing 1142. Busy urban problem solving (minimum spanning tree)
- Clickhouse fields are grouped and aggregated, and SQL is queried according to the granularity of any time period
猜你喜欢
AI 从代码中自动生成注释文档
Mongodb checks whether the table is imported successfully
454 Baidu Mianjing 1
AI automatically generates annotation documents from code
Yunna | work order management measures, how to carry out work order management
制作带照明的DIY焊接排烟器
Today's question -2022/7/4 modify string reference type variables in lambda body
C language - array
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 2)
Dark horse notes - create immutable sets and streams
随机推荐
Public key \ private SSH avoid password login
[signal and system]
Yunna | work order management software, work order management software app
JS reverse -- ob confusion and accelerated music that poked the [hornet's nest]
New job insights ~ leave the old and welcome the new~
新工作感悟~辞旧迎新~
爬虫实战(六):爬笔趣阁小说
AI automatically generates annotation documents from code
Curl command
交叉验证如何防止过拟合
Baidu flying general BMN timing action positioning framework | data preparation and training guide (Part 1)
Share a general compilation method of so dynamic library
JS how to quickly create an array with length n
1123. 最深叶节点的最近公共祖先
Comparison of picture beds of free white whoring
Ds-5/rvds4.0 variable initialization error
Vocabulary in Data Book
对C语言数组的再认识
子网划分、构造超网 典型题
C language instance_ five