How to host multiple ghost blogs on one server

548 views Asked by At

I have a droplet with two domains. Each domain has a subdomain, I am trying to setup two ghost instances on each sub domain but it is giving me a really hard time.

I have a Centos server with a LEMP stack installed. Ghost is running on the first subdomain fine, but the second one I can see the styling of the homepage/front-end, but when I visit /ghost or /admin I get an nginx 404 error not found.

1

There are 1 answers

1
Oleg Konovalenko On

Without your Nginx config file it's difficult to answer, but i will still try, you need to configure nginx to listen for those subdomains, if you have done that successfuly, you also need to configure ghost blog config.js on each blog to have different urls and port and database.

server {
     listen 80;
     server_name  blog1.example.com;

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

     location / {
             proxy_pass http://127.0.0.1:2369/;
             proxy_set_header   X-Real-IP $remote_addr;
             proxy_set_header   Host      $http_host;
     }
 }

blog1.example.com config.js

production: {
        url: 'http://blog1.example.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost1.db')
            },
            debug: false
        },
        server: {
            host: '127.0.0.1',
            port: '2368'
        }
    }

blog2.example.com config.js

production: {
        url: 'http://blog2.example.com',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost2.db')
            },
            debug: false
        },
        server: {
            host: '127.0.0.1',
            port: '2369'
        }
    }