The more astute amongst you may have noticed the slight change in look and feel of my blog. After much faffing about with jekyll-bootstrap I’ve decided to upgrade/switch to Octopress with the Slash theme. I still have a lof of tinkering to do with the theme and layout. Unlike my switch to using Jekyll-bootstrap I’m not going to write any sort of guide as the Octpress docs are absolutely brilliant.
This post will hopefully guide you through building a stable version of Nginx with RTMP support for Ubuntu 12.04 LTS. For anyone who has no idea what RTMP is look at wikipedia and for those who don’t get why it could have anything to do with Nginx check out this site and the Github Repo. This end product should be a collection of deb files which can be installed on any other Ubuntu 12.04 server running the same architecture (might work on other architectures but I’ve never tried).
Before anyone goes overboard in pointing out any flaws, this is just a quick ‘n’ dirty guide. Ideally it would be nice if this was added to the semi-official nginx PPA or added as it’s own PPA. Also please note that this adds the rtmp module to every build (light, full and extras), if you are after efficiency or cleanliness you will probably want to either alter the ‘light’ build or produce your own variant.
I’ll be using a clean install of ubuntu server 12.04 (64bit) for this demo. This can be running anywhere (Amazon EC2, VirtualBox, KVM), I personally prefer using VirtualBox on my macbook to keep everything cleans yet local. In case anyone is interested my current rig for this is VirtualBox 4.1.22 running on OSX 10.8.2 and the VM has 1GB RAM with 2 1.6 Ghz cores.
For this procedure I’ll be using a non-root user (sandfox) that gets created by default during installation, so if you don’t have one please create one. You generally shouldn’t build/compile stuff as root.
To get my vm tooled up I ran the following commands:
sudo apt-get dist-upgrade -y sudo apt-get install build-essential git python-software-properties devscripts sudo add-apt-repository ppa:nginx/stable -y sudo apt-get update
which installs all the necessary build tools bits and bobs and allows us to use the unofficial but well maintained Nginx PPAs
Building the Debs
- First off lets make a folder for a our build activities to take place in and allow our non-root user access: `sudo mkdir /build && sudo chown sandfox:sandfox /build’
- Lets move into the build folder and and unpack the nginx source and while we are at it grab the build dependencies
cd /build && sudo apt-get source nginx
- Move into the source dir
cd nginx-x-y-z && sudo apt-get build-dep nginx-full
- Grab the nginx-rtmp-module source from github and put it into modules folder for the nginx source.
cd debian/modules && git clone git://github.com/arut/nginx-rtmp-module.gitOptionally if you want to go for a particular tag or branch you should run a
git checkout Xin the
- Move back debian directory (‘/build/nginx-x-y-x/debian’ in my case)
- Add the module to the
configurerules in the
rulesfile in the current directory for all the versions (light full, extras). Look for a line similar to the following
--add-module=$(MODULESDIR)...for each version and add this line beneath it
- Make an update to the changelog (as long as it’s in a valid format anything goes) using this command
- Move up one directory (to and rebuild the packages (grab some tea at this point)
cd .. && sudo dpkg-buildpackage -uc -b
Move up one directory and you should find a collection of debs that can be installed using
sudo dpkg -i PACKAGE_NAME.deb (you’ll need to move all the debs to where-ever you wish to install nginx+rtmp)
There is probably alot that can be improved upon with this process so if anyone has any suggestions or finds any problems with the above please let me know either by twitter, email, or raise an issue/PR on the GitHub repo for this blog.
If you want to have a look at the source it’s on Github
It’s currently at version 0.0.2 and probably isn’t that useful to anyone right now unless you happen to have the exact same usage case as seen in the example folder.
If anyone wants to contribute tests, docs, bugs or anything else feel free. Equally if you have any questions fire away via twitter or e-mail.
This should be very easy and take all of 2 mins but turns out it’s full of minor hurdles due to wierd installation behaviour Xcode now exhibits. If you’re wondering why
make can’t be found or for that matter any of the usual build tools you’d expect aren’t to about then read on.
- Install Xcode from the App store
- Open Xcode, then go to the preferences menu and select the Downloads tab. You should be presented with 4 or 5 items of which the bottom one should be Command Line Tools. Click the install button to it’s right, wait a bit for it finish.
- Open a terminal session if you haven’t already and enter this
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/which will tell OSX where it can find Xcode’s developer tools (bizare I know!)
- Download the valgrind source (3.7.0 at time of writing)
- Unpack the source to a suitable directory. I unpacked mine to
/opt/valgrind(don’t ask why - i’m odd)
- If you are not already, open a terminal session and
cdinto the directory where you put valgrind source
- Run this command
./configure --prefix=/usrto configure the source (for some reason using
/usr/binstuck it in
- And this command to make it
- Finally this command
sudo make install
- Test it works by opening a new terminal session and running this command
- Job done! Get writing and profiling some code.
Lets assume you have a fresh install of ubuntu and all you have done is logged in (as a non-root user!)
sudo apt-get update sudo apt-get install python-software-properties sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs npm nodejs-dev
This should be enough to install anything you want from npm (including c/c++ modules) and get any nodejs code written in running by simply typing
A production system should probably have a bit more work and care applied than this!
Why the change?
After enough faffing about with Wordpress and feeling it was the non-developers answer to blogging combined with never quite summing up the energy to go publish anything using it I felt a change was in order. Now, a quick note before the Wordpress Mafia fire up the outrage bus. Wordpress is as CMS/Blogging software goes, pretty awesome. By and large it allows the non-web-developer world to get started with little technical knowledge and have a professional looking and easy to use site quickly, and this can only be seen as a good thing. However as a vaguely technical person, it’s faffy to hack around with and I don’t need 99% of its features. (And some of the codebase still looks the aftermath of a bomb in a alphabeti-spaghetti factory!)
After doing some googling and seeing what all the other cool web kids (TM) were up to I decided the next solution needed to be simple and these were the vague requirements (by no means complete, exhaustive, logical or necessarily what I’ve ended up with):
No database (nope, not even anything NoSQL-ish)
It’s boring to maintain DB servers for something as trivial as a blog, and without caching makes things slow. ALso every good engineer likes to remove the number of moving parts in a system as it tends to mean the run for longer before falling over.
Easy to backup
While what I have to say may not ever change the world, I’d like to keep hold of it and don’t want a simple bit of hardware failure or attack of the fat-fingers to wipe everything out.
Simple to deploy and move around
The freedom and ease to move from one server to another, or one service provider is a must. You never know who will buy who or go bankrupt or decide to let the chaos monkey reign in their server racks.
Teach me something I don’t currently know
Everyday should be a school day.
Customisation/plugins/css-hacks are not mandatory
I don’t want to have to put in a huge amount of effort to hit the “minimum value product” point
I spend alot of time commuting which is a good time to get writing , but mobile signal coverage on the train is largely non-existent. This shouldn’t be a barrier.
Just let me blog!
I don’t want to have alot of hurdles between thoughts popping into my head and something about those thoughts appearing on my blog.
Not be wordpress
This is the largely illogical one, but I’ve suffered enough wordpress extensions/themes pain for one lifetime.
The Solution (so far)
All of the above seemed to point to using some form of static site generator. I’d come across these before but I’d never really delved because either I was feeling lazy at the time or I was having a delusional moment of being happy with wordpress. Then I came across Github’s pages, spent a few hours reading up about how they worked and what on earth Jekyll was, (thought about binning it becuase it was written in ruby) and in a stroke of divine intervention spotted a tweet about Jekyll-Bootstrap before I completely shelved the idea. It’s only taken a couple of hours to get through the basic of getting it up and running on github (using CNAME for those wondering about the domain name). I still need to convert over my old blog posts, customise the theme ever so slightly to sate my need to be different, and possibly tidy up the whatever cruft Jekyll-Boilerplate leaves lying around.