Monday, October 25, 2010

ASP.NET on Mac OS X Snow Leopard at one fell swoop using mod_mono

Enable Apache first by ticking the checkbox for Web Sharing(System Preferences > Sharing > Web Sharing)

Type in browser's address bar, then it should show:

Install gettext first:

Install Mono, get it at:

Verify on Terminal if you have installed Mono...

mono -V

...should show this:
Mono JIT compiler version 2.10.9 (tarball Mon May  7 20:25:51 EDT 2012)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors.
 TLS:           normal
 SIGSEGV:       normal
 Notification:  kqueue
 Architecture:  x86
 Disabled:      none
 Misc:          debugger softdebug 
 LLVM:          yes(2.9svn-mono)
 GC:            Included Boehm (with typed GC)

Paste this in your terminal(the next swoop will still have the effect of sudo(i.e. no need to re-enter password)) :
sudo mv /Library/WebServer/Documents/index.html.en /Library/WebServer/Documents/x_index.html.en

And this(so that makes it two swoop ;-)) :
mkdir ~/swoop
cd ~/swoop
sudo ln -s /Library/Frameworks/Mono.framework/Commands/pkg-config /usr/bin/pkg-config
curl -O
tar xzf mono-2.10.9.tar.bz2
cd mono-2.10.9
sudo make install
sudo sh -c "echo '\n\nInclude /etc/apache2/mod_mono.conf' >> /etc/apache2/httpd.conf"
echo "<center><img src='PoweredByMacOSXLarge.gif'><br><% int a = 7 * 6;%><%=a%> <%=new System.Random().Next()%></center>" > /Library/WebServer/Documents/index.aspx 
sudo /usr/sbin/apachectl restart
echo 'Done'

Then refresh the in your browser, you shall be able to see the the answer to life, the universe and everything

This is the how-to video ...


  1. I would like to know how to run an aspx app with this.... I have mono develop, but when click RUN it wont run it over apache

  2. Configure a virtual directory on Apache to point at your project's path

    If your code changes in MonoDecelop don't immediately take effect in Apache, just restart Apache.

    I don't know how to point the Apache's web root to other directory(mono web project for example) yet, but if found it I'll share it to you

  3. Thanks for this post. One thing worth adding is that a C compiler is needed on your system (e.g. Xcode).

    1. When you upgrade to Lion, and you cannot start the Web Sharing, update your mod_mono to the latest one

  4. So I followed this directions exactly(only difference is using latest version of mod_mono). I can get the powered by Mac .aspx page to load. my problem is when I try to navigate to another project in a subfolder of the same directory I get the following message:

    path attribute must be a relative virtual path. It cannot start with any of ' ' '.' '/' or '\'.

    The project runs fine in Visual Studio or on a production windows server.

    Here is the line in web.config it is referring to

    And y help would be great! I am one step away from ditching Visual Stuidio and Windows for good!