ghost-cli
Ghost CLI
Overview
Ghost-CLI is the official command-line tool for installing and managing Ghost CMS. It handles production setup including MySQL, NGINX, SSL certificates (Let's Encrypt), and systemd process management. It also supports local development installations with SQLite.
When to Use
- Installing Ghost on a server or locally for development
- Configuring Ghost (URL, database, mail, ports)
- Starting, stopping, or restarting Ghost instances
- Updating Ghost to new versions
- Setting up NGINX, SSL, and systemd
- Creating backups
- Diagnosing installation issues
- Managing multiple Ghost instances on one server
Installation
sudo npm install -g ghost-cli@latest
Use @latest to install or update in one command.
Global Flags
| Flag | Description |
|---|---|
--help, -h |
Display usage information |
--verbose, -V |
Enable debug logging |
--version, -v |
Print CLI and Ghost versions |
--dir [path] |
Execute in alternate directory |
--no-prompt |
Skip interactive prompts |
--no-color |
Disable colored output |
Commands
ghost install
Full production installation including MySQL, NGINX, SSL, and systemd:
ghost install # Latest version
ghost install [version] # Specific version (e.g., 5.82.0)
ghost install local # Local dev mode (SQLite, no NGINX)
ghost install --local # Same as above
Options:
| Flag | Description |
|---|---|
--development, -D |
Development environment |
--dir [path] |
Custom install directory |
--archive path/to/file.tgz |
Install from local archive |
--no-stack |
Skip environment validation |
--no-setup |
Skip setup stage |
--no-start |
Skip automatic startup |
--no-enable |
Don't auto-restart on reboot |
--no-prompt |
Non-interactive mode |
Directory structure created:
/var/www/ghost/
├── .config.production.json # Instance configuration
├── .ghost-cli # CLI metadata
├── content/ # Themes, images, data
├── current/ # Symlink to active version
├── system/ # NGINX, systemd, SSL files
└── versions/ # Ghost versions (for rollback)
ghost setup
Configure server components after installation:
ghost setup # Run all setup stages
ghost setup mysql # Create database user
ghost setup nginx # Generate NGINX config
ghost setup ssl # Let's Encrypt SSL
ghost setup nginx ssl # NGINX + SSL combined
ghost setup linux-user # Create ghost system user
ghost setup systemd # Create systemd service
ghost setup migrate # Initialize database
Options:
| Flag | Description |
|---|---|
--no-setup-mysql |
Skip database configuration |
--no-setup-nginx |
Skip web server setup |
--no-setup-ssl |
Skip SSL certificate |
--no-setup-systemd |
Skip process manager |
--no-setup-linux-user |
Skip user creation |
--no-setup-migrate |
Skip database migration |
--pname my-process |
Custom process name |
ghost config
Manage site configuration:
ghost config # Create/view config
ghost config [key] # Get value
ghost config [key] [value] # Set value
ghost config url https://mysite.com # Set site URL
Application options:
ghost config --url https://mysite.com
ghost config --admin-url https://admin.mysite.com
ghost config --port 2368
ghost config --ip 127.0.0.1
ghost config --log '["file","stdout"]'
Database options:
ghost config --db mysql
ghost config --dbhost localhost
ghost config --dbuser ghost
ghost config --dbpass secret
ghost config --dbname ghost_prod
# SQLite (development)
ghost config --db sqlite3
ghost config --dbpath content/data/ghost_dev.db
Mail options:
ghost config --mail SMTP
ghost config --mailservice Mailgun
ghost config --mailuser postmaster@mg.example.com
ghost config --mailpass password
ghost config --mailhost smtp.eu.mailgun.org
ghost config --mailport 465
ghost start
ghost start # Start Ghost
ghost start -D # Start in development mode
ghost start --enable # Enable auto-restart on reboot
ghost start --no-check-mem # Skip memory check
ghost stop
ghost stop # Stop current instance
ghost stop [name] # Stop named instance
ghost stop --all # Stop all instances
ghost stop --disable # Prevent auto-restart
ghost restart
ghost restart # Restart current instance
ghost restart --dir /path/ # Restart specific instance
ghost update
ghost update # Update to latest
ghost update [version] # Update to specific version
ghost update --rollback # Revert failed update
ghost update --force # Force re-download
ghost update --no-restart # Skip restart after update
ghost update --no-auto-rollback # Disable automatic rollback
ghost update --zip path.zip # Update from local archive
ghost update --no-check-mem # Skip memory check
ghost backup
Create a full backup including:
- Content in JSON format
- Member CSV export
- All installed themes
- Images, files, media (video/audio)
routes.yamlandredirects.yaml
ghost backup
ghost doctor
Diagnostic checks for system compatibility:
ghost doctor # Full diagnostics
ghost doctor startup # Configuration validation
ghost doctor setup # Installation verification
ghost doctor --no-check-mem # Skip memory checks
ghost ls
List all Ghost instances with status:
ghost ls
ghost log
View Ghost logs:
ghost log # Last 20 access log lines
ghost log -n 100 # Show 100 lines
ghost log -e # Error logs only
ghost log -f # Follow logs (tail -f)
ghost log -fe # Follow error logs
ghost log [name] # Named instance logs
Log files are stored in content/logs/:
- Access:
https__mysite_com__production.log - Errors:
https__mysite_com__production.error.log
ghost uninstall
Destructive — permanently removes Ghost:
ghost uninstall # With confirmation prompt
ghost uninstall --no-prompt # Skip confirmation
ghost uninstall --force # Force removal
Removes: Ghost process, systemd config, NGINX config, content, and files.
SSL Configuration
Ghost integrates with Let's Encrypt via acme.sh for free SSL:
ghost setup ssl # Interactive SSL setup
- Certificates auto-renew every 60 days
- Ghost supports only one canonical domain (for SEO)
- Redirect additional domains via NGINX
Adding HTTPS Redirect for Additional Domain
ghost config url https://my-second-domain.com
ghost setup nginx ssl
ghost config url https://my-canonical-domain.com
# Edit NGINX config to add: return 301 https://my-canonical-domain.com$request_uri;
sudo nginx -t && sudo nginx -s reload
Manual acme.sh
/etc/letsencrypt/acme.sh --home "/etc/letsencrypt"
File Permissions
Ghost-CLI enforces these defaults:
- Non-root: directories 775, files 664
- Root: directories 755, files 644
Reset if needed:
sudo find /var/www/ghost/* -type d -exec chmod 775 {} \;
sudo find /var/www/ghost/* -type f -exec chmod 664 {} \;
Production Requirements
- Node.js: v22+ (Ghost 6.0)
- Database: MySQL 8 (production), SQLite3 (development only)
- Web Server: NGINX (configured automatically)
- Process Manager: systemd (configured automatically)
- OS: Ubuntu 20.04+ or similar Linux (recommended)
- Memory: Minimum 1GB RAM
Common Troubleshooting
| Issue | Solution |
|---|---|
| Port already in use | ghost config --port 2369 or stop conflicting process |
| Permission errors | Run ghost doctor and fix ownership |
| NGINX config issues | sudo nginx -t to validate, check /etc/nginx/ |
| SSL renewal failure | Run ghost setup ssl again |
| Memory errors | Use --no-check-mem flag or upgrade server |
| Database connection | Verify MySQL credentials with ghost config |
More from bowtiedswan/ghost-cms-skills
ghost-admin-api
Create, update, and manage Ghost CMS content via the Admin API. This skill should be used when creating or editing posts/pages, managing members, newsletters, tiers, offers, tags, users, uploading images/themes, or configuring webhooks. Covers JWT authentication from Admin API keys, the JavaScript SDK (@tryghost/admin-api), Lexical content format, and all CRUD endpoints.
2ghost-webhooks
Ghost CMS webhooks and integrations for event-driven workflows. This skill should be used when setting up webhooks for Ghost events (post.published, member.added, etc.), building custom integrations, automating content workflows, or connecting Ghost to external services. Covers all 31 webhook events, payload handling, JavaScript SDKs, headless CMS setups, and migration tools.
2ghost-content-api
Read-only access to Ghost CMS published content via the Content API. This skill should be used when fetching posts, pages, tags, authors, tiers, or settings from a Ghost publication. Covers authentication with Content API keys, the JavaScript SDK (@tryghost/content-api), NQL filtering syntax, pagination, and all available endpoints.
2