Intermediate
How to self-host Ghost on a VPS
Quick Answer
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
1
Connect to VPS and Update System
Connect to your VPS via SSH and update the system packages:
Install essential packages:
ssh root@your-vps-ip
apt update && apt upgrade -yInstall essential packages:
apt install -y curl wget unzip software-properties-commonTip
Consider creating a non-root user for better security before proceeding with Ghost installation.
2
Install Node.js and npm
Install Node.js 18.x LTS which is required for Ghost:
Verify the installation:
Both commands should return version numbers.
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.
Tip
Ghost requires Node.js 16.x or higher. Always use LTS versions for production environments.
3
Install and Configure MySQL/MariaDB
Install MariaDB server:
Secure the installation:
Create a database for Ghost:
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;Tip
Use a strong password for the ghost database user and write it down as you'll need it during Ghost configuration.
4
Install Ghost CLI and Create Installation Directory
Install Ghost CLI globally:
Create a directory for Ghost and set proper permissions:
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/ghostTip
Never install Ghost in your home directory for production. Use /var/www/ghost or similar system directory.
5
Install and Configure Ghost
Run the Ghost installation command:
Follow the prompts to configure:
The installer will automatically set up Nginx and SSL certificates.
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.
Tip
If installation fails, run 'ghost doctor' to diagnose issues before retrying.
6
Configure Ghost and Create Admin User
Once installation completes, Ghost will start automatically. Visit your domain in a browser and you'll see the Ghost setup screen.
Navigate to https://yourdomain.com/ghost to access the admin panel and create your first user account:
Click Create account & start publishing to complete setup.
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.
Tip
The first user created automatically becomes the owner with full administrative privileges.
7
Configure Firewall and Enable Ghost Service
Configure UFW firewall to allow necessary ports:
Ensure Ghost starts automatically on system boot:
Check Ghost status:
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 statusTip
Regularly update Ghost using 'ghost update' command to keep your installation secure and up-to-date.
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/ghostSSL certificate generation fails
Verify your domain is properly pointing to your VPS IP address and port 80/443 are not blocked:
nslookup yourdomain.comGhost won't start after installation
Check Ghost logs for errors:
ghost log and ensure MySQL service is running: systemctl status mariadbCannot access Ghost admin panel
Verify Nginx is running and configured correctly:
systemctl status nginx and check if Ghost is listening on correct port: ghost statusReady to get started with Ghost?
Put this tutorial into practice. Visit Ghost and follow the steps above.
Visit Ghost →