Tencent Cloud Serverless Framework provides a new deployment method for WordPress based on the serverless architecture. By using the Serverless Framework WordPress component, you can quickly deploy a WordPress project in just a few steps.
This component mainly creates the following resources for you:
Module | Description |
---|---|
SCF | It implements the access layer of Serverless WordPress to run WordPress |
API Gateway | It is the ingress of WordPress and implements RESTful APIs |
CFS | It is the serverless storage warehouse for WordPress |
You can create a TDSQL-C for MySQL serverless database to implement a pay-as-you-go and automatically scalable database service | |
VPC | It is used to connect SCF, CFS, and TDSQL-C Serverless over the private network to ensure network isolation |
Note:Currently, only four regions are supported: Beijing, Guangzhou, Nanjing, and Shanghai.
Note:Currently, only four AZs are supported:
ap-guangzhou-4
,ap-shanghai-2
,ap-beijing-3
, andap-nanjing-1
.
wordpress-demo
folder locally and download the application from the WordPress official website into it.serverless.yml
configuration file and complete application configuration as follows (for more information on the configuration, please see the configuration document):app: wordpress
stage: dev
component: wordpress
name: wordpressDemo
inputs:
region: ap-shanghai # Project region
zone: ap-shanghai-2
src: # Project path, which should be your WordPress path
src: ./wordpress
exclude:
- .env
apigw: # API Gateway configuration
customDomains: # (Optional) Bind a custom domain name
- domain: abc.com # The custom domain name to be bound
certId: abcdefg # Unique certificate ID of the custom domain name to be bound
customMap: true # Whether the path is custom
pathMap:
- path: /
environment: release
protocols: # Type of the protocol of the custom domain name to be bound, which is the same as that of the frontend service protocol
- http
- https
.wordpress-demo
├── wordpress # WordPress source file
├── serverless.yml # Configuration file
└── .env # Environment variable file
sls deploy
to complete the deployment. Below is an example:$ sls deploy
serverless ⚡framework
Action: "deploy" - Stage: "dev" - App: "appDemo" - Instance: "wordpressDemo"
region: ap-shanghai
zone: ap-shanghai-2
vpc:
...
cfs:
...
db:
...
apigw:
created: true
url: https://service-xxxxx.sh.apigw.tencentcs.com/release/
...
layer:
...
wpInitFaas:
...
wpServerFaas:
...
apigw
part, configure the account and password as prompted, and you can start using your WordPress application.SCF_QcsRole
must have the CFSFullAccess permissionCODING_QCSRole
must have the QcloudSLSFullAccess, QcloudSSLFullAccess, and QcloudAccessForCODINGRole permissions{"message":"There is no api match env_mapping '\/'"}
was reported. What should I do?Modify the custom mapping in the API Gateway console as shown below:
php.ini
to change the limit on the size of uploaded files?php.ini
file in the etc
folder to the etc/php.d
folder. You can also directly use the package provided by Tencent Cloud.wp-server-xxx
function as follows:#!/bin/bash
export PATH="/opt/bin:$PATH"
export LD_LIBRARY_PATH=/opt/lib/:$LD_LIBRARY_PATH
export PHP_INI_SCAN_DIR=/opt/etc/php.d
php -d extension_dir=/opt/lib/php/modules/ sl_handler.php 1>&2
Currently, you can only upload an event of up to 6 MB in size for a function. Larger files cannot be uploaded.
Currently, Base64 encoding by API Gateway will increase your code size by 1.5 times. Therefore, we recommend you upload a file below 3.5 MB in size.
Currently, such files are mounted to CFS and cannot be modified directly. We recommend you install the File Manager plugin to manage files in the root directory.
Was this page helpful?