-
Notifications
You must be signed in to change notification settings - Fork 0
Deploy Ghost to EC2
The following document covers the entire process of setting up an EC2 instance and deploying Ghost. This is broken down into 3 stages:
If you already know what you are doing and are just looking for the configure and deploy scripts you can find them here:
- Create an AWS account if you don't already have one. This requires you to login to http://aws.amazon.com/ with your amazon username and password, and then enter credit card details. You shouldn't have to pay anything - we'll use a micro instance which is in the free tier.
- Navigate through "My Account/Console" > "AWS Management Console" > "EC2", or just click here: https://console.aws.amazon.com/ec2/v2/home?region=us-west-2
- Configure your default security group to have ssh, http, and https for all incoming IPs (don't forget to press apply at the end): http://docs.aws.amazon.com/gettingstarted/latest/wah-linux/getting-started-security-group.html
- Get your key (.pem file) and save it in ~/.ssh http://docs.aws.amazon.com/gettingstarted/latest/wah-linux/getting-started-create-key-pair.html
- Hit "Launch Instance"
- use the classic wizard
- choose Ubuntu Server 12.04.2 LTS
- change nothing on the Launch Instances, Advanced Instance Options, or Storage Device Configuration screens
- on the Key-Value screen, enter a sensible name value
- on the Key Pairs screen, choose the Key Pair you setup and saved earlier
- on the Security Groups screen, choose the default security group that you updated earlier
- Hit Launch! You should now have an ec2 instance. You should have a public DNS something like
ec2-xx-xxx-xx-xx.[region].compute.amazonaws.com
. Your username will be ubuntu
- Check everything is ok by sshing to the ec2 instance with the following command, and then exit
ssh -i ~/.ssh/[yourkeyfile].pem ubuntu@ec2-xx-xxx-xx-xx.[region].compute.amazonaws.com
- Save the config script somewhere on your machine which is easy to find.
- Send the config file to ec2 with the following command:
scp -i ~/.ssh/[yourkeyfile].pem /path/to/ghost-ec2-config.sh ubuntu@ec2-xx-xxx-xx-xx.[region].compute.amazonaws.com:~/
- ssh into the ec2 instance again
- run:
sudo chmod u+x ghost-ec2-config.sh
- run:
sudo ./ghost-ec2-config.sh
- create a file in /var/www/index.js - I used the default node.js hello world code: http://nodejs.org/#column1
- navigate to your ec2 in a browser (ec2-xx-xxx-xx-xx.[region].compute.amazonaws.com) and you should see "Hello World"
- You will need an empty directory somewhere on a machine with the following pre-requisites:
- git cli installed with a github ssh key setup
- grunt-cli intalled globally (
npm install -g grunt-cli
) - ruby, ruby sass and ruby bourbon installed
- your .pem saved in ~/.ssh, you can also ask for the .pem for deploying to ghost servers
- Save the ghost-deploy.sh script in your empty directory
- Run the script. It takes a number of arguments:
-
-f | --fork [TryGhost]
- which fork of Ghost to deploy. -
-r | --refspec [master]
- which refspec (branch, tag, commit) to deploy. -
-s | --server [test1]
- which server to deploy to. Options are staging, next or your own ec2 specified by the unique number and region like "ec2-54-214-216-43.us-west-2" -
-p | --pem [ghostdeploy]
- name of the pem file to use to authenticate -
-c | --clean [false]
- delete the clone after deploying
E.g.
./ghost-deploy.sh --server ec2-54-218-37-106.us-west-2 --pem ec2key
would deploy TryGhost master to my own ec2 instance with my key
./ghost-deploy.sh --server staging
would deploy the latest master to staging, providing I have the ghostdeploy.pem file for the ghost servers in .ssh
./ghost-deploy.sh --fork ErisDS --refspec my-branch --server test1 --clean
would deploy my-branch from my own fork to the test1 server and then delete the local clone on my machine, providing I have the ghostdeploy.pem file for the ghost servers in .ssh
4. FINALLY After running the script, you will need to ssh to your ec2 instance and run sudo restart ghost
. I am currently working on finding a way to do this as part of the deploy script.
If you want to deploy a different branch of casper... or want a template for deploying your own them, see the casper deploy script
Re-deploying should simply be a case of re-running the deploy scripts... more instructions here