How to Deploy Strapi to China?
Tags: strapi, contentful, china, cms
Published: 2021-02-18 00:30:37

---
canonical_url: https://www.21cloudbox.com/solutions/how-to-deploy-strapi-project-in-production.html
---
# What is Strapi?

Strapi is an open source code [alternative to Contentful](https://launch-in-china.21yunbox.com/solutions/contentful-alternatives-in-china.html).  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).

<br>
<br>
# 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.

<br>
<br>
## 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](https://www.21yunbox.com/u/signup/)
2. Fork [strapi-postgres](https://gitee.com/eryiyunbox-examples/hello-strapi-postgres)startup template
3. Create a [database](https://launch-in-china.21yunbox.com/solutions/how-to-create-a-postgresql-database.html)
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](https://strapi.io/documentation/v3.x/getting-started/deployment.html#recommended-requirements). 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](https://strapi.io/documentation/v3.x/concepts/configurations.html#configuration-using-environment-variables)

```bash
# Randomly generate 32-bit characters
# Enter on the command line, and paste the generated characters into the environment variable
```

```bash
echo $(base64 /dev/urandom | head -c32)
```

6\. Click "Create Now"

Deployment [Example Video](https://www.bilibili.com/video/BV1Nf4y1k7ZP)

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

<br>
<br>
# How to deploy?
1. Register as a [21YunBox member](https://www.21yunbox.com/u/signup/)
2. Fork [strapi-sqlite](https://gitee.com/eryiyunbox-examples/hello-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](https://strapi.io/documentation/v3.x/getting-started/deployment.html#recommended-requirements?). 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](https://strapi.io/documentation/v3.x/concepts/configurations.html#configuration-using-environment-variables)

```bash
# 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 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]([example video](https://www.bilibili.com/video/BV1fK4y1j7U8))


#### 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](https://www.bilibili.com/video/BV1Ta4y1W7bD)

<br>
<br>
## 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](https://www.youtube.com/watch?v=zd0_S_FPzKg&feature=youtu.be).


<br>
<br>
## 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:

* [21YunBox vs Heroku](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-heroku-in-china.html)
* [21YunBox vs Netlify](https://launch-in-china.21yunbox.com/blog/solutions/alternatives-to-netlify-in-china.html)
* [21YunBox vs Vercel](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-vercel-in-china.html)
* [21YunBox vs Gatsby Cloud](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-gatsby-cloud-in-china.html)
* [21YunBox vs Github Pages](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-github-pages-in-china.html)
* [21YunBox vs Surge.sh](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-surgesh-in-china.html)
* [Compare in terms of function and price: 21YunBox vs Heroku, Netlify, Vercel](https://www.21yunbox.com/compare-others/)


<br>
*This article's content originated [here](https://launch-in-china.21yunbox.com/solutions/how-to-deploy-strapi-project-in-production.html)*

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