DEV Community

Cover image for How to Deploy Strapi to China?
21CloudBox
21CloudBox

Posted on • Updated on • Originally published at 21cloudbox.com

How to Deploy Strapi to China?

What is Strapi?

Strapi is an open source code alternative to Contentful. It was developed based on Node.js, an open source and headless content management system (Headless CMS). When the installation is complete, you can write content and upload pictures on the interface. Finally, you can use API to call the content (returned in JSON form).

How to Deploy Strapi in China

21YunBox provides you with a simple Strapi deployment and hosting solution. You can quickly deploy using 21YunBox in the Node environment.

We provide several different options based on price and performance to fit your needs. We have also prepared two deployment solutions to assist.

Option 1: For Medium and Large Projects: A Solution with Better Performance: Strapi + PostgreSQL

Strapi can be be set up with the following steps:

  1. Register to become a 21YunBox member
  2. Fork strapi-postgresstartup template
  3. Create a database
  4. Create a cloud service on 21YunBox and allow 21YunBox to access your code base (repo)
  5. Configure the parameters
Environment Node 12.19
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 official document

# Randomly generate 32-bit characters
# Enter on the command line, and paste the generated characters into the environment variable
Enter fullscreen mode Exit fullscreen mode
echo $(base64 /dev/urandom | head -c32)
Enter fullscreen mode Exit fullscreen mode

6. Click "Create Now"

Deployment Example Video

Option 2: For small and medium-sized projects, the most cost-effective solution: Strapi + SQLite

How to deploy?

  1. Register as a 21YunBox member
  2. Fork strapi-sqlite startup template
  3. Create a cloud service on 21YunBox, and allow 21YunBox to access your code base (repo)
  4. Configure related parameters
Environment Node 12.19
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)
Enter fullscreen mode Exit fullscreen mode

5. Click "Create Now"

If the description of the above text is not clear, you can refer to the the actual operation video examples:

The first part:

  1. How to deploy Headless CMS Strapi with one-click configuration parameters
  2. How to use environment variables to store sensitive information

How to deploy Strapi to the server-1st: Example Video

The second part:

  1. How to enter development mode by modifying environment variables
  2. Upload sample Shop
  3. How to access interface content

How to deploy a Strapi to the server-2nd: Example Video

R & D Environment

In the R&D environment, you can use yarn develop or strapi develop for R&D and debugging.

For more introductions about Strapi, you can watch Strapi’s official introduction video.

Why Choose 21YunBox?

21YunBox is a Cloud Service platform based out of Beijing. Our services enable your team to be more effective in leveraging the growing opportunity within China by hosting your sites at blazing speeds with an operational and maintenance free solution.

We offer an easy and budget friendly, end-to-end web platform deployment service for all applications from small teams to large enterprises.

Questions about how to get your companies {ICP License for China](https://launch-in-china.21yunbox.com/solutions/how-to-get-an-ICP-license-for-china.html) to legally host your content? Let us know we'd happy to assist.

To learn about the differences between 21YunBox and these foreign (outside of China) cloud service platforms? You can refer to:



This article's content originated here

For additional detail and future modifications, refer the original post.

Top comments (0)