Guide to Deploy Ghost CMS on Cum VPS with Cloudflare Auto Cache Purge on Post Publish
A detailed guide to deploy Ghost CMS on Cum VPS and integrate with Cloudflare to automatically purge cache when publishing posts, ensuring instant content updates.
Image credit: KELLEPICS · Pixabay Content License
Introduction
Ghost CMS is an open-source blogging platform optimized for fast and efficient content publishing. To ensure content updates are visible immediately after publishing, integrating with Cloudflare to automatically purge the cache is essential. This guide walks you through deploying Ghost CMS on Cum VPS and setting up automatic cache purging when a post is published.
System Requirements
- Cloud VPS (Cum VPS) with at least 4GB RAM
- Public IP address
- Node.js (version 16 or higher)
- MySQL or PostgreSQL database
- Registered Cloudflare account
- Ghost CLI tool
Deploy Ghost CMS on Cum VPS
Run the following commands on your VPS to install Ghost CMS:
sudo apt update
sudo apt install -y nodejs npm
sudo npm install -g ghost-cli
ghost install --production
After installation, Ghost CLI will guide you through configuring the database and domain. Make sure to select the "production" option to install the stable version.
Integrate Cloudflare for Auto Cache Purge
To automatically purge the Cloudflare cache when a post is published, set up a Webhook in Ghost CMS that calls the Cloudflare API.
First, obtain your API token from Cloudflare:
- Log in to your Cloudflare account
- Select the website you want to manage
- Go to "API" → "API Tokens" → "Create Token"
- Create a token with permissions "Zone:Cache:Purge" and "Zone:Read"
Then configure the Webhook in Ghost CMS:
ghost config set webhook.url https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/purge_cache
ghost config set webhook.headers.Authorization "Bearer {API_TOKEN}"
ghost config set webhook.events post-published
Replace {ZONE_ID} and {API_TOKEN} with your actual values.
Verify and Test
After configuration, publish a new post and verify the cache is purged:
- Open your browser and visit your website
- Wait a few seconds after publishing
- Refresh the page to check if the new content appears
If the new content appears immediately, the cache purge was successful.
Troubleshooting
- Cache not purged: Verify the API token is correct and has the required permissions.
- Webhook not working: Check Ghost CMS logs for errors.
- Cache not updating: Ensure Cloudflare isn't using stale cache due to DNS or CDN settings.
References
High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-4E
10% VAT included
- CPU: 4 vCPU
- RAM: 8 GB
- SSD: 50 GB NVMe
