How to self-host Ghost on a VPS
Self-hosting Ghost on a VPS involves installing Node.js, MySQL/MariaDB, configuring Ghost CLI, and setting up a reverse proxy with SSL. The process typically takes 30-60 minutes and provides full control over your blog.
Prerequisites
- VPS with Ubuntu 20.04+ or similar Linux distribution
- Domain name pointed to your VPS IP address
- Basic command line knowledge
- SSH access to your VPS
Step-by-Step Instructions
Connect to VPS and Update System
ssh root@your-vps-ip
apt update && apt upgrade -yInstall essential packages:
apt install -y curl wget unzip software-properties-commonInstall Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
apt install -y nodejsVerify the installation:
node --version
npm --versionBoth commands should return version numbers.
Install and Configure MySQL/MariaDB
apt install -y mariadb-serverSecure the installation:
mysql_secure_installationCreate a database for Ghost:
mysql -u root -p
CREATE DATABASE ghost_production;
CREATE USER 'ghost'@'localhost' IDENTIFIED BY 'your-secure-password';
GRANT ALL PRIVILEGES ON ghost_production.* TO 'ghost'@'localhost';
FLUSH PRIVILEGES;
EXIT;Install Ghost CLI and Create Installation Directory
npm install ghost-cli@latest -gCreate a directory for Ghost and set proper permissions:
mkdir -p /var/www/ghost
chown $USER:$USER /var/www/ghost
chmod 775 /var/www/ghost
cd /var/www/ghostInstall and Configure Ghost
ghost installFollow the prompts to configure:
- Enter your blog URL (e.g., https://yourdomain.com)
- Enter your MySQL hostname: localhost
- Enter your MySQL username: ghost
- Enter your MySQL password: your-secure-password
- Enter your database name: ghost_production
The installer will automatically set up Nginx and SSL certificates.
Configure Ghost and Create Admin User
Navigate to https://yourdomain.com/ghost to access the admin panel and create your first user account:
- Enter your site title
- Enter your full name
- Enter your email address
- Create a secure password
Click Create account & start publishing to complete setup.
Configure Firewall and Enable Ghost Service
ufw allow 'Nginx Full'
ufw allow ssh
ufw --force enableEnsure Ghost starts automatically on system boot:
ghost start
systemctl enable ghost_yourdomain-comCheck Ghost status:
ghost statusCommon Issues & Troubleshooting
Ghost installation fails with permission errors
Ensure you're not running as root user and the Ghost directory has correct ownership: chown -R $USER:$USER /var/www/ghost
SSL certificate generation fails
Verify your domain is properly pointing to your VPS IP address and port 80/443 are not blocked: nslookup yourdomain.com
Ghost won't start after installation
Check Ghost logs for errors: ghost log and ensure MySQL service is running: systemctl status mariadb
Cannot access Ghost admin panel
Verify Nginx is running and configured correctly: systemctl status nginx and check if Ghost is listening on correct port: ghost status