/ Ghost

Installing Ghost 1.0 (without ghost-cli)

As you may have noticed things are looking slightly different here. That's because I upgraded Ghost to version 1.0. Really cool version, I love the new editor!

One problem with the update was the installation. Everything related to nehalist.io is hosted on Uberspace - a great hoster. But sadly you can't simply run the Ghost CLI command ghost install and everything works. You run into problems with permissions, you are no root, etc.. It's a shared hoster - I get the point of not being able to sudo commands :)...

Installing Ghost 1.0 without Ghost CLI is interestingly slightly more complicated than I thought it'd be (probably because I've built the thing myself at first...), but still no magic. In case you're running into problems with Ghost CLI just follow the steps below and you should be good.

Different method: installing Ghost as NPM module

Regarding the official docs it's possible to install Ghost as a NPM module, which makes updating way easier than the method below. Detailed instructions on how to do that can be found on the Stickleback blog (thanks to Tom Risager for this information!).

Important note: There's a bug with paths when installing Ghost as npm module; Ghost doesn't use the process directory for finding the content directory specified within the config.<environment>.json and instead uses the Ghost installation directory. That means that the content directory is set to node_modules/ghost/content/, which doesn't make a lot of sense.

As long as this hasn't been officially fixed, a simple workaround is to remove the trailing slash from the contentPath entry in your configuration (hence from contentPath: "content/" to contentPath: "content"). Ghost no longer uses the path as relative path and uses the correct content directory within your ghost installation.

0. Migrate

In case you want to migrate from a previous installation just follow the official guide on how to do that.

1. Install yarn

You actually don't need Yarn, but since Ghost provides a yarn.lock file it might be a good idea to make use of it. Also, generally speaking yarn is just better than npm:

curl -o- -L https://yarnpkg.com/install.sh | bash

2. Download the zip

Initially I just cloned the repo and built the thing myself - don't do that. Just download the latest version, it already includes the built version:

curl -L https://ghost.org/zip/ghost-latest.zip -o ghost-latest.zip

And extract the thing wherever you want to, e.g.:

unzip ghost-latest.zip -d ghost && cd ghost

3. Install dependencies

cd into the directory where you've unzipped Ghost and run

yarn install

to install all dependencies.

4. Configuration

Since we're not using Ghost CLI we need to create the configuration file manually. Gladly there are some predefined environment configurations available within the ghost directory, hence we can simply copy them (into the root directory of the Ghost installation):

cp core/server/config/env/config.production.json config.production.json

Edit the config.production.json to your needs (especially the database settings). Additionally you need to specify the URL and server settings within your configuration file; in the end your file should look something like this:

{
    "url": "<URL_OF_YOUR_BLOG>",
    "server": {
        "host": "127.0.0.1",
        "port": <DESIRED_PORT>
    },
    "database": {
        "client": "mysql",
        "connection": {
            "host"     : "127.0.0.1",
            "user"     : "<DB_USER>",
            "password" : "<DB_PASSWORD>",
            "database" : "<DB_NAME>"
        }
    },
    "auth": {
        "type": "password"
    },
    "paths": {
        "contentPath": "content/"
    },
    "logging": {
        "level": "info",
        "rotation": {
            "enabled": true
        },
        "transports": ["file", "stdout"]
    }
}

5. Knex migrator

Ghost uses a tool namend "Knex migrator" for database migrations. You first need to install it:

npm install -g knex-migrator

After that run

NODE_ENV=production knex-migrator init

This will create all the tables you need for Ghost within your database.

6. Done

That's it. You can now start Ghost with

NODE_ENV=production node index.js

Not using Ghost CLI has probably its downsides, but in case you can't simply run it this might be one solution to get Ghost 1.0 working.

Kevin

Kevin

I make stuff. Mostly functional, occasionally shiny, stuff.

Read More