source code bean

10 Mar, 2012

Deploying your ASP.NET MVC3 site on Mono

Posted by: Peter In: ASP.NET|C#|Mono

In this blog post I am going to show you how easy it is to create a new ASP.NET MVC site and deploy it on Linux/Mono.

Step 1 – Create project
Create a new ASP.NET MVC 3 project. Compile and run it.

Step 2 – Add assemblies needed by Mono
Add references:

Step 3 – Copy local
Make sure to set “Copy Local” to True for all of the following assemblies:
System.Web.Razor (C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll)

Remove Entity Framework and other unnecessary assemblies.

Step 4 – Publish your site
Publish it to a directory and copy it to your Linux server

Step 5 – Get latest Mono and compile it from source
I run Ubuntu 11.10 on my server. Ubuntu has Mono 2.10.6 in its repository, which is quite new, but Mono is moving so fast so I recommend getting the latest version and compiling it from source. The latest version at the time of writing is 2.10.8. Nathan Bridgewater has created a script to simplify this process, if you are running Ubuntu, this is what you will need to run to install Mono:

mkdir mono-2.10
cd mono-2.10
wget --no-check-certificate
chmod 755

It will take a while to compile it, so now is the time to go grab a cup of coffee.

Step 6 – Run your site with xsp4
Mono have a development web server called xsp4, the first thing we are going to do is to run our site in xsp4 to make sure it works. Mono has been installed to /opt, but does not exist in our PATH, so before we can run Mono we need to setup the mono enviroment variables. To do that I found a script somewhere on the internets,

export LD_LIBRARY_PATH=/lib:/opt/mono-2.10/lib:
export C_INCLUDE_PATH=/include:/include
export ACLOCAL_PATH=/share/aclocal
export PKG_CONFIG_PATH=/lib/pkgconfig:/lib/pkgconfig
export PATH=/bin:/opt/mono-2.10/bin:$PATH

At your bash prompt type: source

Now cd into the directory where you have your published web site and run xsp4.

Now your MVC site should be up running on Mono!

In my next blog post I will cover how to configure your site to run using Nginx and the fastcgi-mono server.

2 Responses to "Deploying your ASP.NET MVC3 site on Mono"

1 | Serving your ASP.NET MVC site on Nginx / fastcgi-mono-server4

March 20th, 2012 at 9:20 pm


[...] my previous post I showed you how to compile and install mono and get your MVC site up running using the development [...]

2 | ASP.NET MVC3 Project on Mono « osiutino's Blog

July 7th, 2012 at 3:35 pm


[...] ASP.NET – Mono ASP.NET MVC3 Support Deploying your ASP.NET MVC3 site on Mono Like this:??Be the first to like [...]

Comment Form



Welcome to source code bean! On this site I post stuff that I encounter in my job and spare time. The content is mostly related to .NET development, but my interest in techonology is very broad, so often you will find posts on totally different subjects!