> ## Content Index
> Fetch the complete content index at: https://artofinfra.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Installing Ghost on Ubuntu
- URL: https://artofinfra.com/installing-ghost-on-ubuntu/
- Published: 2024-10-10T03:29:05.000Z
- Updated: 2025-03-30T19:06:02.000Z
- Description: A quick no frills guide to installing Ghost blog on Ubuntu.
- Author: Dan Jones
- Tags: Tutorials, #dan-2, Self Hosted, #Import 2025-08-21 13:12

This is a "No-frills" guide to installing [Ghost](https://ghost.org/?ref=artofinfra.com) and its relevant dependancies on Ubuntu server. 

## Prerequisites

Before beginning the installation process, ensure you have:

1. A Ubuntu server (20.04 or 22.04 recommended)
2. Root or sudo access to the server
3. A domain name pointed to your server's IP address

## Step 1: Update System Packages

First, update your system packages:

```bash
sudo apt update
sudo apt upgrade -y
```

## Step 2: Install Node.js

Ghost requires Node.js to run. Install the recommended version:

```bash
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
```

Verify the installation:

```bash
node --version
npm --version
```

## Step 3: Install MySQL

Ghost uses MySQL as its database. Install it with:

```shell
sudo apt install mysql-server -y
```

Secure your MySQL installation:

```shell
sudo mysql_secure_installation
```

## Step 4: Create a Ghost Database and User

Log into MySQL:

```bash
sudo mysql
```

Create a database and user for Ghost:  
*Change 'your\_password' to your own password and change the username if you wish.*

```sql
CREATE DATABASE ghost_db;
CREATE USER 'ghostuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON ghost_db.* TO 'ghostuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

## Step 5: Install Ghost-CLI

Ghost-CLI is a command-line tool for installing and managing Ghost:

```bash
sudo npm install ghost-cli@latest-g
```

## Step 6: Create Ghost Directory

Create a directory for your Ghost installation:

```bash
sudo mkdir -p /var/www/ghost
sudo chown $USER:$USER /var/www/ghost
sudo chmod 775 /var/www/ghost
cd /var/www/ghost
```

## Step 7: Install NGINX

Install NGINX:

```bash
sudo apt install nginx
```

Ensure NGINX is running:

```bash
sudo systemctl status nginx
```

If its not running, start it manually:

```bash
sudo systemctl start nginx

```

Enable NGINX to start on boot:

```bash
sudo systemctl enable nginx

```

## Step 8: Install Ghost

Now, install Ghost using the Ghost-CLI:

```bash
ghost install
```

During the installation, you'll be prompted to enter various details:

- Blog URL: Enter your domain (e.g., [https://yourdomain.com](https://yourdomain.com/?ref=artofinfra.com))
- MySQL hostname: Usually 'localhost'
- MySQL username and password: Use the ones you created earlier
- Ghost database name: 'ghost\_db'

Accept the prompts to set up Nginx and SSL.

## Step 9: Configure Nginx (if not done automatically)

If Nginx wasn't set up automatically, create a configuration file:

```bash
sudo nano /etc/nginx/sites-available/ghost
```

Add the following configuration (replace yourdomain.com with your actual domain):

```nginx
server {
    listen 80;
    server_name yourdomain.com;
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
    }
}
```

Enable the configuration:

```bash
sudo ln -s /etc/nginx/sites-available/ghost /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
```

💡

Make sure to point your DNS A record to your server IP.

## Step 10: Set Up SSL (if not done automatically)

If SSL wasn't set up automatically, you can use Certbot:

```bash
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com
```

## Step 11: Start Ghost

If Ghost isn't already running, start it:

```shell
cd /var/www/ghost
ghost start
```

## Accessing Your Ghost Blog

You can now access your Ghost blog at [https://yourdomain.com](https://yourdomain.com/?ref=artofinfra.com). The admin panel is available at [https://yourdomain.com/ghost](https://yourdomain.com/ghost?ref=artofinfra.com).

Remember to keep your Ghost installation updated by periodically running:

```bash
cd /var/www/ghost
ghost update
```