I spent a couple of frustrating weeks trying to get an ASP.NET MVC web application that had been developed on a Windows machine, using IIS and MS SQLServer, to run on an Ubuntu machine, using Apache and MySQL.
Here are the instructions for posterity.
Get Mono working on your Ubuntu machine
Install Mono (the .NET framework): http://www.mono-project.com/docs/getting-started/install/linux/
Install mod_mono (ASP.NET): see http://www.mono-project.com/docs/web/mod_mono/
Check that a file named test.aspx in the otherwise empty folder where you want your project runs correctly.
Your apache config file should look something like:
<VirtualHost *:80>
ServerName my.domain
ServerAlias *.my.domain
DocumentRoot /var/www/virtual/my.domain
ErrorLog /var/log/httpd/my.domain_error_log
CustomLog /var/log/httpd/my.domain_access_log combined
HostnameLookups Off
UseCanonicalName On
MonoAutoApplication disabled
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
MonoApplications PROJECTNAME "my.domain:/:/var/www/virtual/my.domain"
MonoExecutablePath PROJECTNAME /usr/bin/mono
MonoServerPath PROJECTNAME /usr/bin/mod-mono-server4
<Directory "/var/www/virtual/my.domain">
MonoSetServerAlias PROJECTNAME
SetHandler mono
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
If you get "Error 503, temporarily unavailable" then you need to get the correct VirtualHost. You cannot use MonoAutoApplication with MVC, because MVC does not include extensions. Generate a config file here instead: http://go-mono.com/config-mod-mono/
See http://www.vbforums.com/showthread.php?524548-RESOLVED-mod_mono-with-apache for other discussion.
In /etc/mono-server4/???.webapp:
<apps>
<web-application>
<name>???</name>
<vpath>???</vpath>
<path>???</path>
<vhost>???</vhost>
</web-application>
</apps>
Copy dlls into the project bin folder
You want the following dlls (assuming you are using EntityFramework to connect to a database)
Your project dll
Any libraries - your own or other people's - that it depends on (e.g. BeginCollectionItem)
EntityFramework
EntityFramework.SqlServer (possibly)
Newtonsoft.Json (I think)
The following System.Web dlls:
.Helpers
.Mvc
.Razor
.Webpages
.Webpages.Deployment
.Webpages.Razor
You do not want the following:
Microsoft.Web.Infrastructure.dll
This should be the .dll from mono, not the one from Microsoft (which will be included in the project by default, and should be deleted from the bin for the project on your server).
System.Web.dll
If you have this in your project bin on your Mono server, you will get: Error 503 Service Temporarily Unavailable. Or you will get an error 500, "couldn't bind to method SetHostingEnvironment".
System.Web.Routing.dll
See http://devblog.rayonnant.net/2012/11/mvc3-working-in-mono-ubuntu-1210.html for advice.
Copy the Content folder, Controllers folder, Scripts folder, and Views folder.
Troubleshooting
Missing method System.Web.Security.FormsAuthentication::get_IsEnabled()
Check that you have the correct version of Mono for what you are trying to do. Check also that you are not accidentally using dlls for the wrong version of MVC!
Error 404: cannot find Index
You are using the wrong combination of web.config specifications and dlls. Check all your dlls. Check both your web config pages. Make sure all the web.config references match the dll versions - especially MVC and web routing.
Set up database
Install MySQL, if you haven't already.
If you are using EntityFramework code first (and possibly even model first), do not create a database instance. Load a page on your site, and EntityFramework will do that for you.
Add dlls
On Windows or Ubuntu, you need to include: MySQL.Data.Entity.EF6.dll, from the Connector/Net project.
You also need the relevant Migrations folder, with MySQLHistoryContext and Configuration. (documented ???)
For installation on Ubuntu, you will also need to download the .dlls for .Net/Mono. See http://dev.mysql.com/doc/connector-net/en/connector-net-installation-unix.html.
Copy the v4 files into the bin of your project (MySql.Web, MySql.Data, MySql.Data.Entity, MySql.Data.Entity.EF6)
You must register the Connector/Net component, "MySql.Data", in the Global Assembly Cache (GAC). In the current directory enter the gacutil command:
root-shell> gacutil /i MySql.Data.dll
This will register MySql.Data into the GAC. You can check this by listing the contents of /usr/lib/mono/gac, where you will find MySql.Data if the registration has been successful.