TLDR; This Strapi tutorial provides you with a step-by-step solution to deploy and host your Strapi Headless CMS in China.
What is Strapi CMS?
Strapi is an open source headless CMS (content management system) built with Node. It comes with a great admin graphical user interface that let your entire content team create and manage content for your websites and apps. Strapi also makes your content available via APIs and can therefore be used in many different ways.
How to Deploy Strapi in China?
21YunBox is Strapi’s recommended deployment and hosting solution for China. You can quickly deploy using Node runtime on 21YuBox.
Depending on how you’re using Strapi, your needs will vary when you deploy your project to production. In this guide we’ll describe two different methods you can use to deploy Strapi in China on 21YunBox, and help you pick the best one for your project.
Option 1 for China: For medium and large projects: Optimize for Scale and Uptime
Strapi can be be set up with the following steps:
- Signup on 21YunBox
- Fork strapi-postgres starter
- Create a database
- Create a Cloud Service on 21YunBox, and allow 21YunBox to access your repo
- Use the following values during creation
Runtime | Node |
---|---|
Build command | yarn && yarn build |
Start command | yarn start |
For the choice of configuration, Strapi official documentation suggests Use at least 2GB for servers with memory and 1 core CPU, if you choose a machine with less memory for deployment, the deployment may fail.
Click Advanced Configuration to configure the environment variables
Environment Variable Key | Environment Variable Value |
---|---|
NODE_ENV | production |
DATABASE_URL | Click Database URL in the cloud database console to get |
JWT_SECRET | Randomly generate 32-bit characters* |
ADMIN_JWT_SECRET | Randomly generate 32-bit characters* |
For other related environment variables, please refer to Strapi’s official document
# Randomly generate 32-bit characters
# Enter on the command line, and paste the generated characters into the environment variable
echo $(base64 /dev/urandom | head -c32)
6. Click “Create Now”
Step-by-step screencast to show above steps in action
Option 2 for China: For small and medium-sized projects: Optimize for Cost and Simplicity
Strapi can be be set up with the following steps:
- Signup on 21YunBox member
- Fork strapi-sqlite starter
- Create a Cloud Service on 21YunBox, and allow 21YunBox to access your repo
- Use the following values during creation
Runtime | Node |
---|---|
Build command | yarn && yarn build |
Start command | rsync -a public/ /data/public/ && yarn start |
In terms of choice of configuration, Strapi official documentation suggests Use at least 2GB For servers with memory and 1 core CPU, if you choose a machine with less memory for deployment, the deployment may fail.
Click Advanced Configuration to configure environment variables
Environment Variable Key | Environment Variable Value. |
---|---|
NODE_ENV | production |
DATABASE_FILENAME | /data/strapi.db |
JWT_SECRET | Randomly generate 32-bit characters* |
ADMIN_JWT_SECRET | Randomly generate 32-bit characters* |
For other related environment variables, please refer to strapi official document
# Randomly generate 32-bit characters
# Enter on the command line, and paste the generated characters into the environment variable
echo $(base64 /dev/urandom | head -c32)
5. Click “Create”
A Step-by-step screencast to master the basic of Strapi
The first part of the screencast shows you:
- How to deploy a Headless CMS Strapi in minutes
- How to use environment variables to store sensitive information
The second part of the screencast shows you:
- How to switch to
development
mode by modifying a environment variable - how to add a new
Shop
in Strapi CMS - How to access
Shop
information via API.
For more tutorials about Strapi, you can check out Strapi’s official introduction video