Deploying your ASP.NET MVC3 site on 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
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:
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.10.sh
chmod 755 install_mono-2.10.sh
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, monoenv.sh:
At your bash prompt type: source monoenv.sh
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 thoughts on “Deploying your ASP.NET MVC3 site on Mono”