目录

Installing Ghost on a Simple Hosting NodeJS / MySQL instance

We will see in this tutorial how to install Ghost in only a few minutes on a Simple Hosting NodeJS / MySQL instance.

In this tutorial, we will use the Gandi CLI to simplify the installation and deployment. To install and configure Gandi CLI, navigate to http://cli.gandi.net

Instance creation and installation preparation

First, we will create the instance :

$ gandi paas create --name Ghost --type nodejsmysql --duration 1m
password: 
Repeat for confirmation: 
Creating your PaaS instance.

We will then clone the repository (which will be empty because we just created the instance) :

$ gandi paas clone Ghost

We will then navigate to the 'default' directory, which is where our application code must reside, followed by downloading and decompressing the Ghost application from the official website :

$ cd default
$ wget https://ghost.org/zip/ghost-0.6.4.zip
$ unzip ghost-0.6.4.zip && rm ghost-0.6.4.zip

Creation of the database and the associated user

We will now connect to the console of the instance to create a database and user named 'ghost', as well assign the proper rights :

$ gandi paas console Ghost

hosting-user@Ghost:~$ mysql -u root

mysql> CREATE DATABASE ghost;
Query OK, 1 row affected (0.01 sec)

mysql> CREATE USER ghost;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON ghost.* to 'ghost'@'localhost' identified by 'RRTCPDK%';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Ghost Configuration

We will copy the sample configuration file provided by Ghost :

$ cp config.example.js config.js

Then we will edit the file :

    production: {
        url: 'http://38bc76daec.url-de-test.ws',
        mail: {},
        database: {
            client: 'mysql',
            connection: {
                socketPath  : '/srv/run/mysqld/mysqld.sock',
                user        : 'ghost',
                password    : 'RRTCPDK%' ,
                database    : 'ghost',
                charset     : 'utf8'
            },
            debug: false
        },

        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '127.0.0.1',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '8080'
        }
    },

For the last step of the configuration, we will rename the file 'index.js' to 'server.js' :

$ mv index.js server.js

Deploying the application

We are now ready to deploy the application on the instance :

$ git add .
$ git commit -am "First commit with Ghost source files and setup"
$ git push origin master
$ gandi deploy

Once done, your application should then be available at the website address you specified. In this example, we did not use add a new virtual host, but used the default vhost provided when the instance is created.