RSS feed for blog Linkin Skype Mail Me Twitter

Stickfight

Migrating to Markdown Pt2 Nuts and Bolts

Setting up the awesome Statamic on Amazon EC2 and syncing via Dropbox is straight forward and once set up is dead reliable, I love the fact that I can edit files anywhere I can access Dropbox and they appear straight away on my site(s) with backups all sorted

Prerequisites

A) A drop box account, I would recommend a new one just for this otherwise you end up either having stuff you don’t need on the server or having to exclude loads of directories which have to be updated every time you add a new one, just get a standard free one to start with as that will give you 2 gig plus data and that is well enough, then just share the directory you will be storing your website in with your normal dropbox account.

B) An Amazon web services account you will need one of these as that is where the site will actually be hosted.

C) A licensed version of Statamic

Soo..
  • Create a EC2 instance (just use the quick start wizard) using Amazon Linux AMI 2012.09 (32 bit)

  • I prefer static IP address, so these instructions assume you have requested a ‘Elastic IP’ address and associated it with your new EC2

(I’m not putting in blow by blow instructions for creating an EC2 as the Amazon AWS site is as easy as their shopping one, kick me if you need full instructions )

Once you have your EC2 instance up you will need to connect to it via SSH for the Linux and Mac boys this is easy, you can just open up a terminal, for windows peasants I would recommend putty, use the command below remembering to have your pem (the security file you created when you make the EC2) file in the same directory as the one your are running the command from.

ssh -i xx.pem ec2-user@xx.xxx.xxx.xxx


Now you are on the server we want to install Apache and php, this is dead easy

sudo yum install httpd php


Next we will be installing Dropbox with the following command ( note: that this is for the 32 bit version )

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -


Next, start the Dropbox daemon which will try and run drop box on the server

~/.dropbox-dist/dropboxd


If you’re running Dropbox on your server for the first time, you will be asked to copy a link into a browser, do this and when asked to log into your new Dropbox account,

While you’re there create a folder in your Dropbox that you are going to store the site in, in this example mine will be called “XXXXX”

you will see that a folder called ‘Dropbox’ will be created in your server’s (or more precisely the ‘ec2-user’) home directory.

(by the way I had to do a ctrl-c to get my prompt back so I could carry on)

Now we need a cool little package called Dropbox.py, this is the Dropbox command line tool.

$ wget -O ~/dropbox.py "http://www.dropbox.com/download?dl=packages/dropbox.py"


(we are storing it in our home directory root, so when you are calling it, you will either have to be in your home directory or reference it as ~/dropbox.py)

Now we’re going to add a symbolic link. This links our Dropbox folder to our web root. first run this command to stop drop box

python dropbox.py dropbox stop


This should give you the message ‘Dropbox daemon stopped’. Now Link the Apache www root to your new website directory on Dropbox

ln -s /var/www ~/Dropbox/XXXXX


Next you will have to change some security rights so that drop box can write to these directories

sudo chown -R $USER /var/www
sudo chmod -R u+rw /var/www


and restart Dropbox

python ~/dropbox.py dropbox start


you will now find that the contents of the www directory is appearing in your Dropbox folder. :)

you should see 4 folders , ‘cgi-bin’ , ‘error’ , ‘icons’ and ‘html’

extract the contents of your Statamic zip download into the ‘html’ directory

that should be it really and you should just be able to go to the IP address and see the default Statamic website, but I got a odd error message regarding default date formats when I tried it.

to fix this we need to set a timezone in your php.ini file, edit your php.ini file like this

sudo vi /etc/php.ini


find the “data.timezone” by typing

/timezone


It will most likly be like this

date.timezone = ""


I changed mine to

date.timezone = "Europe/London"


To update a file in VI, press “I” to go to edit mode, change the text, then press the escape key to move out of edit mode and “:x” to save and exit.

vi is a bit of a pain to use, you can find a nice reference here

That should be it, Statamic should work fine and you should be able to see the default website and update it via Dropbox.

Extra Notes

If you want to use the online content manager for Statamic you will need to set the following security so that it can write to directories

sudo chmod -R 777 /var/www/html/_config/users/
sudo chmod -R 777 /var/www/html/_content/


and finally you want the Dropbox daemon to restart if the server gets restarted

so enter

crontab -e


This will give you a blank text file in vi (see above on how to navigate in vi)

add the following line and save

@reboot ~/.dropbox-dist/dropboxd


kick me if anything is unclear.

Leave Your Comments

blog comments powered by Disqus
Latest Blogs