How to Deploy a Ghost Project?
Tags: ghost, china, webdev, node
Published: 2021-03-10 23:56:07

---
canonical_url: https://www.21cloudbox.com/solutions/how-to-install-a-self-hosted-ghost-blog.html
---
# What is Ghost?
Ghost is a free and open source blogging tool created with NodeJS. It is also used to build and run modern blogs, magazines and periodicals.

# How to Deploy Ghost in China

21YunBox provides a very simple Ghost deployment method. Since there are different scenerios, we have prepared two deployment options for you.

## Solution 1: For Medium and Large Projects, the Best Performance Solution: Ghost + MySQL

Ghost blogs are generally used in conjunction with MySQL databases, which is also the combination suggested by [Official Document](https://ghost.org/docs/hosting/#self-hosting).
This solution is equipped with an independent MySQL database, the performance will be better, and it can support more users to read your blog at the same time!

### Ghost Deployment

1. Register as a [21YunBox member](https://www.21yunbox.com/u/signup/)
2. Create a [MySQL database](https://launch-in-china.21yunbox.com/solutions/how-to-create-a-mysql-database.html)
3. Click "Hosted Application" in the navigation menu, then select "Ghost"

In terms of choosing service configuration, Ghost official documentation suggests [https://ghost.org/docs/hosting/#self-hosting](https://ghost.org/docs/hosting/#self-hosting) Use at least 1GB RAM and 10GB cloud disk. If you choose a machine with fewer cloud disks for deployment, the deployment may fail.
{: .notice--warning}

4\. Click **Advanced Configuration** and add the following environment variables:

| Environment Variable Key         | Environment Variable Value      |
| -------------------------------- | :------------------------------:|
| `NODE_ENV`                       | `production`                    |
| `url`                            | `https://<app_id>.21yunbox.com` |
| `database__client` | `mysql`     |                                 |
| `database__connection__host`     | MySQL host name                 |
| `database__connection__database` | MySQL database                  |
| `database__connection__user`     | MySQL username                  |
| `database__connection__password` | MySQL user password             |

For other Ghost environment variable configurations, please refer to Ghost official documentation: [https://ghost.org/docs/config/#configuration-options](https://ghost.org/docs/config/#configuration-options)


5\. Click "Create Now"

Before you know it, your Ghost is deployed online and you can access it through `https://<app_id>.21yunbox.com/ghost`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vdvpwqozs9yshz7nwsa.png) *Ghost blog server deployed successfully*

### Operation Video
If you are not sure how to perform the above steps, you can watch this [example video](https://www.bilibili.com/video/BV1oK4y1n73K)


## Solution 2: For Small and Medium-sized Projects, the most cost-effective solution is Ghost + SQLite

The Ghost blog also supports deployment schemes used in conjunction with SQLite databases. This is **not an official recommendation** combination. If it is a small or medium-sized project with a small number of users, this configuration is sufficient.

### Ghost Deployment
You can deploy Ghost to the server through the following steps:

1. Register as a [21YunBox member](https://www.21yunbox.com/u/signup/)
2. Click "Hosted Application" in the navigation menu, then select "Ghost"

In terms of choosing the service configurations, Ghost official documentation suggests [https://ghost.org/docs/hosting/#self-hosting](https://ghost.org/docs/hosting/#self-hosting) Use at least 1GB RAM and 10GB cloud disk. If you choose a machine with fewer cloud disks for deployment, the deployment may fail.
{: .notice--warning}

3\. Click **Advanced Configuration** and add the following environment variables:

| Environment Variable Key| Environment Variable Value      |
| ----------------------- | :------------------------------:|
| `NODE_ENV`              | `production`                    |
| url                     | `https://<APP_ID>.21yunbox.com` |

If additional configurations are needed, please refer to Ghost official documentation: [https://ghost.org/docs/config/#configuration-options](https://ghost.org/docs/config/#configuration-options){: target="_blank"}

In a matter of seconds, you will be able to access your deployment through `https://<app_id>.21yunbox.com/ghost`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vdvpwqozs9yshz7nwsa.png) *Ghost blog server deployed successfully*

4\. Click "Create Now"

## Configure a Custom Domain Name

21YunBox provides a simple [custom domain name configuration](https://www.21yunbox.com/docs/#/custom-domains), when you complete [ICP record](https After ://www.21yunbox.com/docs/#/beian). You will only need to add a custom domain name in "Settings", and then change the main domain name by modifying the environment variable `url`, as follows:

| Environment Variable Key | Environment Variable Value    |
| ------------------------ | :----------------------------:|
| `url`                    | `https://www.your-domain.com` |


## Configure Sending Mail Service

If you need to use Ghost to send mail, you can use a third-party mailing service provider, such as [Mailgun](https://www.mailgun.com/), they support a quota of 10,000 emails per month.

Take Mailgun as an example. After you create an account and related Token, you can use the following environment variables to configure:

| Environment Variable Key    | Environment Variable Value                  |
| ----------------------------| :------------------------------------------:|
| `mail__transport`           | `SMTP`                                      |
| `mail__options__service`    | `Mailgun`                                   |
| `mail__options__auth__user` | Sending email address configured in Mailgun |
| `mail__options__auth__pass` | Password configured in Mailgun              |

If you use other sending mail service providers, you can refer to Ghost's official documents to configure yourself [https://ghost.org/docs/concepts/config/#mail](https://ghost.org/docs/concepts/config/# mail).

When the configuration is complete, click "Update Configuration" in the upper right corner, 21YunBox will help you restart Ghost and configure the mail service.

# Why Choose 21YunBox?

> 21YunBox is a Cloud Service Platform based out of Beijing, China. We specialize in modern web hosting and automation solutions. This enables you to set up websites instantly.  

> **Have questions about hosting and deploying in China? Let us know, we are happy to help!** <21YunBox@gmail.com> 

To learn about the differences between 21YunBox and these foreign (outside of China) cloud service platforms, please 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-install-a-self-hosted-ghost-blog.html)*

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