Disclaimer: this post is definitely sponsored by 6sync – they bake delicious virtual servers.
This is great for a couple of reasons. Firstly, Live Unsigned has a decent server in which to grow. Secondly, and most importantly, it meant I had a blank canvas to work with to get the server exactly as I wanted it. Things like this are fun! The setup I went with in the end was Debian 6, Nginx, MySQL, PHP5.3 (with PHP-FPM), Memcache and finally postfix for the mail serving. Following is a little description of each step required.
Mario from 6Sync gave us a “Mini” account. This consists of 512 MB ram and 2 CPUs. I’m going to write a more detailed review on the actual server soon, so I won’t put any further detail here. Needless to say it is more than enough to last Live Unsigned a good while yet.
My stack of choice these days is Nginx, MySQL and PHP on top of a rock solid Debian base.
I like Debian a lot. It’s stable, it’s simple and there is lots of documentation out there. 6sync’s server control panel comes with a base install of Squeeze, so it really was a no-brainer. After installing the base image on the server, running apt-get update and apt-get upgrade the base memory footprint was 20MB.
There are lots of articles out there about setting up a base Debian installation and securing the firewall etc. However, to make it more like home for me, I immediately installed Tmux:
apt-get install tmux
and coloured up the command promt:
by adding this line to the end of the file
PS1='[e[1;33m]u@h:[e[0;36m]W[e[m] [e[1;32m]$[e[m] [e[0;37m]'
Nginx is becoming more and more popular. It uses far less resources and is less memory hungry than Apache. It is the ideal choice when running a VPS as it enables you to squeeze so much more out of the hardware. Apart from the odd Node project, most stuff I do these days I gear towards serving it with Nginx.
It is getting easier to set up, but it still requires a bit of hacking about to get it just right. Fortunately there are some great tutorials out there, so I won’t bore you with hashing over the same old stuff.
If you are going to play around with Nginx and PHP I highly recommend reading Neal Pool’s blog post about not trusting the tutorials!
PHP and PHP-FPM
Unlike Apache, Nginx does not have a module for running PHP. Instead FastCGI is used to handle the PHP processes. Since PHP5.3, a new processor manager is available: PHP-FPM. This is the first time I’ve used PHP-FPM, and it is impressively speedy. It’s a doddle to set up on Debian, and is clearly explained in this thread on Web Hosting Talk.
What with all the hype over NoSQL databases these days, I feel somewhat dirty for still using MySQL. However, for a site like Live Unsigned it is pretty much the closest fit. One day, when we have millions of users a day, we’ll possibly have to readdress this, but for now, it fits the bill.
Whilst the primary use of the 6Sync server hosting Live Unsigned is for the website, it still needs to be able to send out emails (registration activation etc). My default choice for the mail sending daemon is Postfix. it’s far simpler to configure than Exim and works pretty much out of the box. See this tutorial for more details. The only thing to consider is that the “mynetworks” configuration in main.cf restricts who can send mail to the local machine:
mynetworks = 127.0.0.0/8
Finally, after everything was up and running, we installed and enabled memcache. For pages with heavy use that don’t change too much (such as the homepage, or landing pages for each country or city) the generated output is cached with memcache. This makes the pages lightening fast to load, and the quicker the pages are to load, the more chance there is of the user hanging around to browse and use the site.
Once the website is installed, configured and running we needed to make sure it stays that way. As such we need some monitoring tools to firstly help it stay up and secondly tell us if it goes down.
The first line of defense is Monit. The time taken to install and configure vs the utility it provides makes it a complete no brainer. The basic premise of Monit is listen to a bunch of processes defined by in the configuration. If one of the processes goes down, try to restart it. If it can’t restart for whatever reason, alert the sysadmin. Also it can restart and/or alert the sysadmin if the CPU usage gets out of hand, or memory usage is too high etc. All in all a really useful little tool.
3rd Party Services
Both at Live Unsigned and Jabbakam, we use a number of 3rd party monitoring services. Two notable ones are Wormly and Cloudkick. More details can be found on their websites. Both provide you with peace of mind that if anything does happen to your servers, you’ll be told about it.
Getting a brand spanking new server is always fun. The possibilities are there to set it up exactly how you want. Setting up the new Live Unsigned server took a couple of days researching, testing things out, tweaking and generally playing – which is great fun for me. The server is now in a state where it has been up and running for about a month and has been 100% reliable (famous last words). It uses less than half the 512MB of Ram and is ticking away with almost zero load.
All in all I’m really happy with it. It’s a great server and should give us plenty of room to grow.
A massive thanks to Mario and the rest of the 6Sync guys for sponsoring Live Unsigned. Whilst I have tried to make this post as unbiased as possible, I can honestly say, if you need yourself a perfectly baked server, go grab yourself one from 6sync.