Geeks With Blogs

News This is the *old* blog. The new one is at
Elton Stoneman
This is the *old* blog. The new one is at

That’s a slightly sneaky title, but let’s see how we get on.
Nginx is a fast and lightweight Web server which runs on Linux and Windows. Like Node.js it runs on a single thread, processing requests asynchronously through an event loop, rather than using the thread-per-request model of Apache and IIS. That means it’s very light on memory and CPU and should be able to scale to large numbers of concurrent requests.
Nginx started on Linux and the Windows version is a bit of a poor relation (“should be considered a beta” according to the docs). It doesn’t have feature parity - Nginx can run as a caching proxy but for that it needs shared memory and it can’t work with Windows’ address layout randomization; and it doesn’t have performance parity - it’s not so tightly integrated with the OS event loop as on the Linux versions, so it doesn’t run as quickly or scale as highly.
So if you want to try out Nginx on Linux with an Azure VM, these four commands will do it for you:
1. Create  VM from standard Ubuntu image with PowerShell*:

New-AzureQuickVM -Linux -ImageName b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_2-LTS-amd64-server-20130624-en-us-30GB -InstanceSize Small -Password Quit3C0mplex -Location "North Europe" -ServiceName "u-svc-name" -Name "u-vm" -LinuxUser azureuser

2. Login to VM with SSH (e.g.
PuTTY on Windows, Terminal on Mac):

3. Install Nginx from Ubuntu’s repository:

sudo apt-get install nginx 

4. Start Nginx:

sudo service nginx start

That’s it! You have Nginx running on an Azure Linux VM. If you’re happy with SSH and the strange experience of editing files with vi, then you can upload your web content, edit your nginx.conf to configure the server and you’re good to go.
But if you want a friendlier experience, then you need to do a little bit more. To RDP into the machine and set it up using the UI, you can install the desktop and an RDP server with a couple more SSH commands:
sudo apt-get install ubuntu-desktop 
sudo apt-get install xrdp

In the Azure console, add an endpoint mapped to the internal port 3389 for the VM, and you can now RDP into your machine, and you’ll get the XRDP login screen:


Log in with the user credentials you specified in New-AzureQuickVM and you’ll be straight to the Ubuntu desktop:
Which makes it easier to grab your content from S3 or wherever you have it, and edit your nginx.conf using a more intuitive editor.
The version of Nginx available in the repositories is usually a few steps behind the latest release, so if you want the latest features you can undo the previous install:

sudo apt-get  --purge remove nginx 

- and build the latest release from source.

TheHippo has an excellent blog post with 6 steps to install nginx from source on Ubuntu. The only changes I made were the version of Nginx to download (1.4.1 being the current stable release):

tar xvzf nginx-1.4.1.tar.gz

- and installing zlib before running ./configure, to support Nginx gzipping responses:
sudo apt-get install zlibc zlib1g zlib1g-dev

Now you have the latest version of Nginx installed, check out Dakini’s blog on Tuning Nginx for Best Performance – where she lists the values of the nginx.conf setup she used to get 900,000 requests per second served by one server. 

To execute the New-AzureQuickVM cmdlet, there are a few pre-requisites:
PowerShell installed and configured with Set-ExecutionPolicy RemoteSigned
Azure PowerShell commands installed
Download the publishing profile for your Azure subscription
Set your subscription & storage account in PowerShell:

Set-AzureSubscription -SubscriptionName my-sub-name -CurrentStorageAccount my-vhd-storage 

To get the image details for the most recent release of the Ubuntu 12.04 LTS Azure image, use:
get-azurevmimage | where {($_.Label -eq "Ubuntu Server 12.04.2 LTS") } |sort-object PublishedDate -descending | select -f 1 
Posted on Wednesday, July 3, 2013 9:37 AM Azure , Nginx , Linux | Back to top

Comments on this post: From 0 to Nginx on Linux on Azure in 4 commands

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Elton Stoneman | Powered by: