ASP.NET MVC on Ubuntu with NGINX

We’ve just published an early working version of an on-line service created by NewRedo, however, although written in ASP.NET MVC 2, it’s not running on a Microsoft server. Instead we’re running on Ubuntu 11.10 using the NGINX web server.

First, a little about the service. It’s a system for booking time off work, and keeping track of the time you’ve booked off. Although it’s in a very early stage, it’s usable right now and we will not lose any data when it finally goes ‘live’. To try this please visit FlitHub.

Ubuntu 11.10 server edition comes comes with very little installed, but by adding just two packages you can have yourself an ASP.NET web server. These packages are installed as follows:

apt-get install nginx mono-fastcgi-server4

This will automatically install Mono if it’s not there already, and it set’s up a web site on port 80. The gory details of the setup can be found on the mono website in their article FastCGI Nginx. However, we opted for a few deviations. For our system, I created a new configuration file in /etc/nginx/sites-available, and hard linked that into /etc/nginx/sites-enabled, just like you would with Apache HTTP Server. Also, rather than editing the installed configuration files, I included the extra fastcgi_param directives in our site configuration file. Upgrades and repairs are slightly easier if you avoid changing configuration files that are provided by the package installation.

I had a little trouble running the FastCGI server with the right parameters. I found that omitting the domain name worked best:

fastcgi-mono-server4 /applications=/:/var/www/ /socket=tcp:

I won’t cover getting this all working at start-up as there is a sample script on referenced on the Mono FastCGI article, simply copy this and make the appropriate adjustments. When I get time I hope to write a generic startup script that uses configuration from /etc/fastcgi-mono-server4 to find the websites.

One other consideration was the server memory. We created a cloud-based server with 256MB of memory to see how it would handle the load. After starting the system and hitting a few pages we found that the server is running happily with 33MB spare.

To summarise Ubuntu 11.10 can run ASP.NET applications perfectly well on a small virtual server.

Author: Phill Luby

Phill is a Software Developer and Co-founder of NewRedo Ltd.