On this page
Ghost-CLI is Ghost’s command-line tool. It installs, configures and updates Ghost for you, on your own computer or on a server. This guide covers both: a local install for building or changing a theme, and a production install on Ubuntu, the stack Ghost recommends.
Note
A Ghost-CLI install can’t run Ghost’s built-in web analytics, and it uses Ghost’s hosted service for the social web. To self-host both, use Ghost’s Docker setup (opens in a new tab) (in preview) instead. Or skip the server work with Ghost(Pro) (opens in a new tab). See Ghost hosting options to compare.
What you need
For a local install:
- macOS, Windows or Linux.
- A supported Node.js version (opens in a new tab): Ghost 6 runs on Node.js 22 or 24, the two LTS versions Ghost supports. Use the latest release of either.
- Python 3 and setuptools, to build SQLite3, the database used locally.
- An empty folder.
For a server:
- Ubuntu 22.04, 24.04 or 26.04, with at least 1 GB of memory. On DigitalOcean, the Ghost 1-Click App does most of this for you: see Self-hosting Ghost on DigitalOcean.
- NGINX, MySQL 8.0 or 8.4, and Node.js 22 or 24 (step 3 installs them).
- A domain name, with a DNS A record pointing to the server’s IP address. Set it up before you install, so SSL can be configured.
1. Install Ghost-CLI
Install it globally with npm:
npm install ghost-cli@latest -gOn a server, run it with sudo. Then ghost --help lists every command. The ones you’ll use most:
ghost start,ghost stopandghost restartghost updateto update Ghostghost configto change settings such as the URLghost logto read the logsghost lsto list every Ghost install on the machine, and whether it’s running
2. Install Ghost locally
In your terminal, go to an empty folder and run:
ghost install localWhen it’s done, your site runs at http://localhost:2368, and Ghost Admin at http://localhost:2368/ghost.
A local install runs in development mode, with less caching, which suits theme work. The SQLite3 database is in content/data/, and themes go in content/themes/. Ghost keeps running in the background until you run ghost stop or restart your computer.
That’s all for a local install. The next steps are for a server.
3. Prepare your server
Log in to your server as root and create a user to run Ghost with. Don’t call it ghost: that name conflicts with Ghost-CLI.
adduser <user>
usermod -aG sudo <user>
su - <user>Update the system, then install NGINX and open the firewall for it:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo ufw allow 'Nginx Full'Install MySQL:
sudo apt-get install mysql-serverOn Ubuntu, MySQL’s root user logs in through the system socket, which Ghost doesn’t support. Give it a password:
sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH 'caching_sha2_password' BY '<your-new-root-password>';
FLUSH PRIVILEGES;
exitInstall Node.js 22 or 24 from NodeSource, system-wide, with the commands in How to upgrade Node.js for self-hosted Ghost (steps 1 and 2). Then install Ghost-CLI as in step 1.
4. Install Ghost on your server
Ghost needs its own folder, owned by your user. Replace sitename and <user>:
sudo mkdir -p /var/www/sitename
sudo chown <user>:<user> /var/www/sitename
sudo chmod 775 /var/www/sitename
cd /var/www/sitenameThen run the install:
ghost installGhost-CLI checks your system, downloads Ghost and asks a few questions.
5. Answer the install questions
- Blog URL: the full address of your site, with
https://, for examplehttps://example.com. Don’t use an IP address. - MySQL hostname:
localhostwhen MySQL runs on the same server. Press Enter for the default. - MySQL username and password:
rootand the password you set in step 3. - Ghost database name: Ghost creates it for you.
- Set up a ghost MySQL user? Yes. Ghost-CLI creates a MySQL user that can only reach the Ghost database.
- Set up NGINX? Yes.
- Set up SSL? Yes. Ghost-CLI gets a free Let’s Encrypt certificate and renews it. It asks for an email address for certificate notices.
- Set up systemd? Yes. It keeps Ghost running and starts it again after a reboot.
- Start Ghost? Yes.
If the install stops halfway, run ghost setup to pick up the configuration again. If it goes badly wrong, run ghost uninstall and start over, rather than deleting the folder.
6. Create your account and set up email
Go to https://example.com/ghost and create the owner account.
Then set up email. Ghost needs it for staff invites, password resets and member sign-in links, and it sends newsletters through Mailgun. Follow How to set up Mailgun email in Ghost.
The result
Ghost runs on your server behind NGINX, with HTTPS and a MySQL database, and systemd keeps it running. Keep it up to date with ghost update: the Ghost version history lists what each release changes. Check Ghost’s supported Node.js versions before a major update. Next, pick a look for your site: browse our Ghost themes.