ASP.NET MVC on Ubuntu with NGINX

ASP.NET MVC on Ubuntu with NGINX

Phill Luby
9th December 2011

Home Insights 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/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000

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.

Share Article

Insights.

Taking a look at Dagger
Taking a look at Dagger

Solomon Hykes is probably most famous for being the founder and former CTO of Docker. Docker revolutionised the way we package, run and distribute server applications, so when Hykes starts a new venture, it's worth checking out.

Discover More
Running Terraform in a Lambda Function
Running Terraform in a Lambda Function

I recently set up a Terraform project which I wanted to run on a regular schedule. There are a number of ways to achieve this, but I decided to package the project as a Lambda function and schedule it with… 

Discover More
Setting up AWS SSO with Google Workspace
Setting up AWS SSO with Google Workspace

I recently configured Single Sign On (SSO) from our Google accounts to AWS. AWS SSO is the recommended way to configure SSO across multiple AWS accounts, yet Google is not a supported identity provider. However, this simply meant that there… 

Discover More