/ Ghost

Install Ghost on your EC2 Linux AMI

This is for those of you who have NodeJS setup and running on your Amazon EC2 Linux AMI, and now want to start running the new Ghost blog platform. If you don't already have NodeJS running and serving sites on your server, take a look at my previous post.

Here's what I did to get ghost up and running:

Steps

[1] Ghost requires NodeJS v0.10.* as a minimum, which you can install using the guide in my last post for your Amazon Linux AMI instance. Install instructions are available here: http://docs.ghost.org/installation/.

Go to https://ghost.org/signup/ and signup for an account with Ghost to get news on updates and releases. Login and download the latest zip file on your server. When I first wrote this post, Ghost v0.3.3 was the latest although now v0.4 is now available. I used the following commands to download and install ghost on my EC2 server logged in as the ec2-user:

      wget https://ghost.org/zip/ghost-0.3.3.zip
      mkdir /var/www/node/ghost
      mv ghost-0.3.3.zip /var/www/node/ghost
      cd /var/www/node/ghost
      unzip ghost-0.3.3.zip
      npm install --production

This last command will download and install NodeJS library dependancies for the ghost platform. You may see some errors while installing the required libraries; for example, this is one I encountered on my Amazon Linux AMI:

Error: /lib64/libc.so.6: version 'GLIBC_2.14' not found (required by /var/www/node/ghost/node_modules/sqlite3/lib/binding/Release/node-v11-linux-x64/node_sqlite3.node)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/node/ghost/node_modules/sqlite3/lib/sqlite3.js:7:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)

This is a fairly common error as shown in http://docs.ghost.org/installation/troubleshooting/. This is actually ok if you see the following lines of output:

[sqlite3]: Attempting source compile...
make: Entering directory 		'/var/www/node/ghost/node_modules/sqlite3/build'
ACTION 	deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3071700/sqlite3.c
TOUCH Release/obj.target/deps/action_before_build.stamp
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3071700/sqlite3.o
AR(target) Release/obj.target/deps/sqlite3.a
COPY Release/sqlite3.a
CXX(target) Release/obj.target/node_sqlite3/src/database.o
CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
CXX(target) Release/obj.target/node_sqlite3/src/statement.o
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node: Finished
COPY Release/node_sqlite3.node
make: Leaving directory '/var/www/node/ghost/node_modules/sqlite3/build'
[sqlite3]: Created: lib/binding/Release/node-v11-linux-x64
[sqlite3]: Installed in lib/binding/Release/node-v11-linux-x64/node_sqlite3.node
[sqlite3]: Sweet: "node_sqlite3.node" is valid, node-sqlite3 is now installed!

If not, you'll have to try and build sqlite3 from source using npm install sqlite3 --build-from-source and then rerunning npm install --production

If you don't get any further errors, then ghost should be ready to run.

[2] We need to test to make sure NodeJS can run ghost properly before starting configuration and customization of the new blog.

In your ghost installation directory (/var/www/node/ghost for this example), type:

 npm start

and you should see the following text, which means Ghost is installed and running correctly:

> [email protected] start /var/www/node/ghost
> node index

Ghost is running...
Listening on 127.0.0.1:2368
Url configured as: http://my-ghost-blog.com
Ctrl+C to shut down

This shows an new instance of ghost running and listening on port 2368. Let's update the port and reverse proxy to properly serve the new blog on your server to the outside world.

[3] As shown in my my previous post, I use NodeJS and Http-proxy to reverse proxy my incoming web traffic to the appropriate server(NodeJS or Apache sites). This is done inside a file called proxy.js which contains the routes for http-proxy to use. For ghost, I added the following route to the routes table used by http-proxy:

      'blog.angelengineering.com':'127.0.0.1:2368' 

For ghost, the default port is 2368, which we can change by editing the config.js file and changing the server section. For example, the following block is found in config.js under the "development" server block.

	server: {
        host: '127.0.0.1',
        port: '2368'
    }

To change what port Ghost listens on, simply update this file and restart ghost in the appropriate mode. npm start --production' for your production version or npm start for the development version. After changing the port used by Ghost, also remember to update the route file with the new port number.

With a port and proxy route configured, I can now go to http://blog.angelengineering.com/ghost to setup my admin user and start configuring the ghost platform.

[4] Now comes the fun part. After you've created your admin user, login and update the Settings with info like your name, the blog name and any profile or background pics you'd like to use.

You'll probably also want to experiment with themes if you'd like something nicer than the default Casper theme. I suggest looking at the Ghost Marketplace which offers a variety of free and paid themes for ghost. You can also take a look at ThemeForest which sells a number of ghost themes as well.

Once you've found a few themes you'd like to experiment with, download and install them to your ghost site by added theme directories to /var/www/node/ghost/content/themes/. You can look at an example here on downloading a free theme and installing it for use with ghost.

Add your first post to ghost and experiment!