This is a guide to help you setup a Ghost blog manually, using Amazon Web Services infrastructure, in the most simple steps.
I highly recommend reading Gregg Housh's guide as well, he provides some excellent security additions to the setup process that have not been included here.
Step 1: Setup EC2 instance
Log into Amazon Web Services (I’ll refer to this as AWS from now on). Go to the EC2 section and Launch a new instance.
Choose Amazon Linux 64bit, choose a relevant Security Group that has port 22 open to your IP, choose a relevant keypair that you have stored in an accessible but secure place. Launch!
Step 2: Connect and configure Linux
Log into your new instance using Putty or other SSH tool.
Note: I usually connect an AWS ‘elastic’ (public) IP to the instance as soon as I launch it, and therefore always connect to the same IP. Elastic IP’s aren’t free however.
Once you have a command prompt, follow these commands…
- Type: sudo yum updateThis updates the linux components to their latest versions. Choose ‘y’ when asked to proceed.
- sudo yum install gcc-c++ make
- sudo yum install openssl-devel
- sudo yum install gitThese install dev tools to build the node stack.
- git clone git://github.com/joyent/node.git
- cd nodeThis downloads Node, next we’ll build it.
- sudo git checkout v0.10.22
At time of writing this was the latest stable Node build. Ghost requires a v0.10.x, you should be able to take a later one if it exists
- sudo make
Go make a coffee.. this may take up to 30 mins
- sudo make installNode is now installed.
- sudo vim /etc/sudoersPage down until you find this line:Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/binMove to the end of the line, press i and you should be in insert mode, paste this::/usr/local/bin
There should be no spaces in the line. Now press Esc, then :w!, then :q
Next we install NPM which is package manager for Node, and is also required for Ghost.
- sudo git clone https://github.com/isaacs/npm.git
- cd npm
- sudo make install
I’ve found that if you run this as root you get permissions errors. The best way is to run it as the ec2-user using sudo. If you need to fix it up after the fact, running this section as ec2-user should fix it: sudo node cli.js install -g -f
Step 3: Installing Ghost!
You’ll need to create a directory that your Ghost blog will sit under. I usually do this elsewhere but we’ll use the ec2-user’s home dir for this example, /home/ec2-user. If you type “cd ../..” we’re back at the home dir.
Updated 18-11-13: Thanks to jgillich for pointing out the initial security issue in this guide that has been corrected.
- mkdir ghostThe blog dir is now created, time to download and install Ghost
- wget https://ghost.org/zip/ghost-0.3.3.zip
- unzip *zip
- rm -rf *zipOnce completed you have the base Ghost install. (There’s more to do though)
- npm install –productionThis installs module dependencies via NPM, the Node package manager
- npm start
You should see a few lines indicating the server is running – good news! Press ctrl+c to return to the command line.
- vim config.jsWe’ll edit the config settings here for your specific blog. Using page up/down scroll through the file and find the sections relating the dev and production. Each have a server IP, url and port associated with them. You need to change the url to your blog e.g. “http://www.bybigs.com“, leave the port but remember the number, and change the server IP to the private IP of your instance. In your AWS console you’ll find it by selecting your instance and finding “Public IPs” amongst the other instance details at the bottom. To save and exit press Esc, :w, :q
If you now run “npm start” again your blog will be accessible on your domain and correct port e.g. http://www.bybigs.com:2368. If you want it to be accessible once you close the SSH session (most likely!) then we need to install forever – another NPM module.
So, type “npm install forever -g” and once that’s done you can start the server by typing “NODE_ENV=production forever start index.js”, and you can close the SSH window.