I had a time getting my cheap linux box hosting configured to host my ASP.NET MVC 3 application. These notes are how I got it working using mono 2.6.10 on my Arch Linux 200510
In this example I setup a directory to host my application (I will get to what files and how later) I placed these files in the ‘/srv/http/mysite’ folder.
1. Install mono, lighttpd and fcgi on the box
pacman -Sy pacman -S mono lighttpd fcgi
2. Setup lighttpd to use FastCGI edit the ‘/etc/lighttpd.conf’ file and modify this line;
server.document-root = "/srv/http/mysite"
3. Add this line to the end of your ‘/etc/lighttpd.conf’ file;
include "fastcgi.conf"
4. Put this into your ‘/etc/lighttpd/fastcgi.conf’ file;
include "mono.conf" server.modules += ( "mod_fastcgi" ) fastcgi.server = ( "" => (( "socket" => mono_shared_dir + "fastcgi-mono-server4", "bin-path" => mono_fastcgi_server, "bin-environment" => ( "PATH" => "/bin:/usr/bin:" + mono_dir + "bin", "LD_LIBRARY_PATH" => mono_dir + "lib:", "MONO_SHARED_DIR" => mono_shared_dir, "MONO_FCGI_LOGLEVELS" => "Standard", "MONO_FCGI_LOGFILE" => mono_shared_dir + "fastcgi.log", "MONO_FCGI_ROOT" => mono_fcgi_root, "MONO_FCGI_APPLICATIONS" => mono_fcgi_applications ), "max-procs" => 1, "check-local" => "disable" )) )
5. Put this in your ‘/etc/lighttpd/mono.conf’ file;
index-file.names += ( "index.aspx", "default.aspx", "Default.aspx" ) var.mono_dir = "/usr/" var.mono_shared_dir = "/tmp/" var.mono_fastcgi_server = mono_dir + "bin/" + "fastcgi-mono-server4" ### The root of your applications # For apps installed under the lighttpd document root, use: var.mono_fcgi_root = server.document-root ### Application map # A comma separated list of virtual directory and real directory # for all the applications we want to manage with this server. The # virtual and real dirs. are separated by a colon. var.mono_fcgi_applications = "/:."
Make sure you didn’t fat monkey up the conf files by doing this;
$ lighttpd -t -f /etc/lighttpd/lighttpd.conf
Should return a “OK”
Now go into your ASP.NET MVC app and setup the references to be “Copy Local” True on these assemblies (if you don’t have the assembly reference by the project add it, you might need to look in “Assemblies -> Extensions” to find some of these) ;
System.Web.Helpers.dll System.Web.Helpers.xml System.Web.Mvc.dll System.Web.Mvc.xml System.Web.Razor.dll System.Web.Razor.xml System.Web.WebPages.Deployment.dll System.Web.WebPages.Deployment.xml System.Web.WebPages.dll System.Web.WebPages.Razor.dll System.Web.WebPages.Razor.xml System.Web.WebPages.xml
Make sure you DO NOT have the Microsoft.Web.Infrastructure.dll file, it doens’t work with Mono and causes errors.
Now just publish your project to a folder somewhere, then go into that folder and get the entire contents to the ‘/srv/http/mysite’ folder. Sure you can setup FTP and all that fanciness but I just use WinSCP and copy directly from my publish folder into the ‘/srv/http/mysite’ folder.
Now start lighttpd on the box and you should have the joy of ASP.NET MVC 3.
Enjoy!
References;
http://www.mono-project.com/Release_Notes_Mono_2.10#ASP.NET_MVC3_Supporthttp://redmine.lighttpd.net/wiki/1/Docs:Configuration
https://wiki.archlinux.org/index.php/Lighttpd
http://www.mono-project.com/FastCGI_Lighttpd
I think “xsp” is also needed for this to work, i.e.:
pacman -S mono lighttpd fcgi xsp
Hi,
A new MVC2 project works ok, but on MVC3 i have this error:
‘The resource cannot be found.’
Rui
Okay, got it working.
There was one (temporary) problem and one thing to be added to your instructions.
First, it looks like mirrors.kernel.org isn’t working properly today. This led to some tail-chasing. If others are having this problem, then simply uncomment one or more mirrors from /etc/pacman.d/mirrorlist. You’ll have better luck that way.
Assuming that pacman -S works for you (see above), you’ll also need to download and install these packages:
wget http://mirror.rit.edu/archlinux/extra/os/i686/libgdiplus-2.10-1-i686.pkg.tar.xz
wget http://mirror.rit.edu/archlinux/extra/os/i686/mono-2.10.2-1-i686.pkg.tar.xz
wget http://mirror.rit.edu/archlinux/extra/os/i686/xsp-2.10.2-1-i686.pkg.tar.xz
(I was using the RIT mirrors, YMMV).
Then:
pacman -Uf libgdiplus-2.10-1-i686.pkg.tar.xz
pacman -Uf mono-2.10.2-1-i686.pkg.tar.xz
pacman -Uf xsp-2.10.2-1-i686.pkg.tar.xz
After installing these packages, you should be able to find:
/usr/bin/fastcgi-mono-server4
at which point Steven’s instructions above work fine.
Thanks!
M.
That’s so cool!!