This topic describes how to deploy a WordPress application to Function Compute. Function Compute provides a method different from traditional deployment methods. You can deploy a traditional WordPress application to Function Compute and use the application for production without performing operations such as purchasing a server. The deployed WordPress application can use the auto scaling, pay-as-you-go, and O&M-free features of Function Compute.

Prerequisites

The following operations are complete:

Procedure

  1. Run the following command in the specified directory to initialize a project:
    s init devsapp/start-wordpress -d start-wordpress
    The -d parameter specifies the project name. In this example, the project name is start-wordpress.
    Note Skip this step if the item exists.
    Sample command output:
     Serverless Awesome: https://github.com/Serverless-Devs/package-awesome
    
     devsapp!start-wordpress@0.0.16.zip file decompression completed
     please select credential alias default
    
         _    _               _
        | |  | |             | |
        | |  | | ___  _ __ __| |_ __  _ __ ___  ___ ___
        | |/\| |/ _ \| '__/ _` | '_ \| '__/ _ \/ __/ __|
        \  /\  / (_) | | | (_| | |_) | | |  __/\__ \__ \
         \/  \/ \___/|_|  \__,_| .__/|_|  \___||___/___/
                               | |
                               |_|
    
    
        Welcome to the start-wordpress application
         This application requires to open these services:
             FC : https://fc.console.aliyun.com/
             ACR: https://cr.console.aliyun.com/
         This application can help you quickly deploy the Wordpress project:
             Full yaml configuration   : https://github.com/devsapp/wordpress#%E5%AE%8C%E6%95%B4yaml
             Wordpress development docs: https://cn.wordpress.org/support/
         This application homepage: https://github.com/devsapp/start-wordpress
    
    
     Thanks for using Serverless-Devs
     You could [cd /test/start-wordpress] and enjoy your serverless journey!
    ️ If you need help for this example, you can use [s -h] after you enter folder.
     Document Star: https://github.com/Serverless-Devs/Serverless-Devs
  2. Run the following command to go to the project directory:
    cd start-wordpress
  3. Run the following command to deploy the project:
    s deploy
    Sample command output:
    [2021-08-31T15:38:41.895] [INFO ] [S-CLI] - Start ...
      devsapp!wordpress@0.0.7.zip file decompression completed
     Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
    (node:20419) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)
      End of request
      Deployed.
      End of request
    [2021-08-31T15:39:05.035] [INFO ] [FC-DEPLOY] - Using region: cn-shenzhen
    [2021-08-31T15:39:05.036] [INFO ] [FC-DEPLOY] - Using access alias: default
    [2021-08-31T15:39:05.036] [INFO ] [FC-DEPLOY] - Using accessKeyID: 188077086902****
    [2021-08-31T15:39:05.036] [INFO ] [FC-DEPLOY] - Using accessKeySecret: KdcUEJLoGto****
     Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
    [2021-08-31T15:39:05.812] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-wordpress exists
    [2021-08-31T15:39:06.269] [INFO ] [FC-DEPLOY] - Setting role: AliyunFCDefaultRole
    [2021-08-31T15:39:06.662] [INFO ] [RAM] - Checking Role AliyunFCDefaultRole exists
    [2021-08-31T15:39:06.812] [INFO ] [RAM] - Updating role: AliyunFCDefaultRole
    [2021-08-31T15:39:06.915] [INFO ] [RAM] - Checking Plicy AliyunFCDefaultRolePolicy exists
    [2021-08-31T15:39:07.044] [INFO ] [FC-DEPLOY] - Using vpcConfig: auto: fc will try to generate related vpc resources automatically
    [2021-08-31T15:39:07.742] [INFO ] [VPC] - Getting vpc: fc-deploy-component-generated-vpc-cn-shenzhen
    [2021-08-31T15:39:07.827] [INFO ] [VPC] - Getting vswitch: fc-deploy-component-generated-vswitch-cn-shenzhen
    [2021-08-31T15:39:07.953] [INFO ] [VPC] - Getting securityGroup: fc-deploy-component-generated-securityGroup-cn-shenzhen
    [2021-08-31T15:39:08.131] [INFO ] [FC-DEPLOY] - Generated vpcConfig:
    securityGroupId: sg-wz92ctigpi221smc****
    vSwitchId: vsw-wz9qnuult4q5g4f7n****
    vpcId: vpc-wz9x9bzs0wtvjgt6n****
    
    [2021-08-31T15:39:08.132] [INFO ] [FC-DEPLOY] - Using nasConfig: auto: fc will try to generate related nas file system automatically
    [2021-08-31T15:39:33.582] [INFO ] [FC-DEPLOY] - Generated nasConfig:
    groupId: 10003
    mountPoints:
      - fcDir: /mnt/auto
        nasDir: /serverless-devs-wordpress
        serverAddr: example.com
    userId: 10003
    
    [2021-08-31T15:39:33.584] [INFO ] [FC-DEPLOY] - Checking Function wordpress exists
    [2021-08-31T15:39:33.710] [WARN ] [FC-DEPLOY] - Image registry.cn-shenzhen.aliyuncs.com/web-framework/php7:0.0.3 dose not exist locally.
    Maybe you need to run 's build' first if it dose not exist remotely.
    [2021-08-31T15:39:33.713] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-wordpress exists
    [2021-08-31T15:39:33.819] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-wordpress exists
    [2021-08-31T15:39:33.948] [INFO ] [FC-DEPLOY] - Creating service: serverless-devs-wordpress
    [2021-08-31T15:39:33.948] [INFO ] [FC-DEPLOY] - Creating function: wordpress
    [2021-08-31T15:39:33.949] [INFO ] [FC-DEPLOY] - Creating triggers: ["serverless-devs-wordpress"]
      Make service serverless-devs-wordpress success.
      Make function serverless-devs-wordpress/wordpress success.
      Make trigger serverless-devs-wordpress/wordpress/serverless-devs-wordpress success.
    [2021-08-31T15:39:37.108] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-wordpress exists
    [2021-08-31T15:39:37.186] [INFO ] [FC-DEPLOY] - Checking Function wordpress exists
    [2021-08-31T15:39:37.425] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-wordpress exists
    [2021-08-31T15:39:37.656] [INFO ] [FC-DEPLOY] - Creating custom domain: wordpress.serverless-devs-wordpress.188077086902****.cn-shenzhen.fc.devsapp.net
    [2021-08-31T15:39:38.449] [INFO ] [FC-DOMAIN] - Creating custom domain: wordpress.serverless-devs-wordpress.188077086902****.cn-shenzhen.fc.devsapp.net
    
    There is auto config in the service: serverless-devs-wordpress
    [2021-08-31T15:39:39.116] [INFO ] [WEB-FRAMEWORK] - nas component get src is: ./code
    Packing ...
    Package complete.
     Start uploading file: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-wordpress/wordpress/code.zip
      File uploaded successfully: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-wordpress/wordpress/code.zip
      upload done
    [2021-08-31T15:40:54.700] [INFO ] [FC-NAS] - unzipping file
    [2021-08-31T15:41:01.442] [INFO ] [FC-NAS] - unzip done
      Try container acceleration
    framework-test:
      region: cn-shenzhen
      serviceName: serverless-devs-wordpress
      functionName: wordpress
      customDomains:
        - >-
          http://wordpress.serverless-devs-wordpress.188077086902****.cn-shenzhen.fc.devsapp.net

Result

After the project is deployed, you can view the temporary domain name generated by Function Compute in the execution output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application:

curl http://wordpress.serverless-devs-wordpress.188077086902****.cn-shenzhen.fc.devsapp.net
Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. You must use a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud for production. For more information, see Configure a custom domain name.