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](http://www.lagmonster.org/docs/vi.html)
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.

Missing in Action

Well, how long has it been since I have written to my blog?. The answer is bloody ages and the reason is work. LDC has simply been flat out with work. With both day work and all nighters. The months have been stuffed with a mixture of major client work, smaller independent projects and community actions such as presentations for conferences such as UKlug and IBM connect. ( which I will talk about In the next blog entry) in fact I am writing this entry sat in bed as I can’t sleep on my first early night in months which strikes me as bloody dumb.

Anyway this entry is mainly a year in review and a look to the future in case people read my blog during IBM connect and wonder why I have been so lazy.

This year has been quite amazing, with the work I have been doing at LDC really showing me where I want to go in the future. The variety of work as well as the variety of clients has been staggering from hideously complex websites to training, from nasty nasty Java to Amazon Web services consultation

Most of all I have been very lucky with the people I have been working with, its quite the most amazing thing to be the dumbest person on the team as you learn shit loads on each project (although it’s terrifying to see how fast Julian can Code, the quality of Matts design and the fact that that even the bloody wretch Ben Poole is getting even better at UI design) and that’s not even including the partners we have worked with such as Gab and Mike from the Turtle partnership ( if anyone says they can keep up with Gab or know a better project manager than Mike then they are a fibber and need a kick in the fork)

Continuing on with this theme will be 2013. Keeping up with all the tech and business design that clients seem to need at the drop of a hat, though I’m fairly sure my brain won’t hold much more than it currently seems to be stuffed with but what is life with out the odd challenge

🙂

What a difference a year makes

last year at the Canadienne Arcachon bay.

this year

It was a wild night last night. It was a fantastic aire 9 individual bays with picnic seats facing the canal but in trees.

During the might the wind got up and bits of branches were dropping on the roof, waking us up with a start. There were 7 campers in when we went to bed by morning there were only 3. This is a picture of the camper roof in the morning the bigger branches had bounced off.

like of the day

Pizza take away in front of the aire.

dislike of the day

Cockerels on site that crow at 5am

No wi fi

Well I didn’t think these places exist any more No wi-fi No phone signal so I will post this when we get back to civilisation. We are in the Caravan Club site at Rosedale Abbey in the heart of the Yorkshire
Dales

It’s a quiet site in a quiet village that only comes to life at weekends. Sandra and Brian came up to see us on Sunday and we had a good Sunday lunch in the pub ‘it was great to see them. Today we have been for a walk up to the head of Rosedale and back down a old iron ore railway track.

While walking through the village I got talking to the village gardener / handyman who was starting to get things ready for the village show next weekend. I asked him was it a good show he replied “We have tractors, cows, sheep and this year we even have goats” He was also worried what he was going to do tonight,the local pub was closed for a private function, and he was barred from the top house. So he did not know how he would spend the evening. For all you golfers out there, this is a picture of the 5th green at Rosedale golf course.

It isn’t Lake Garda!!