[Updated 2/11/09: Included information about my experience in making a fresh build on a fresh install of Leopard]
Getting a Macintosh to serve up ASP.NET content is actually pretty simple. Mono's primary support for ASP.NET comes through an Apache plugin called mod_mono. This is very good news for the Mac user because Apache version 1.3 comes as part of Tiger. As long as you don't need to run other plugins that require newer versions of Apache (like Subversion), setting up ASP.NET on a Mac could scarcely be easier.
Prerequisites:
~/src/mono
)Here's what you need to do:
~/src/mono
.svn checkout svn://anonsvn.mono-project.com/source/trunk/mod_mono
.~/src/mono/mod_mono
and run the command ./autogen.sh --prefix=/Library/Frameworks/Mono.framework/Versions/Current
.autogen.sh
and configure
were failing because a tool named libtoolize
was renamed to glibtoolize
, and the configuration scripts were not configured to handle this. You can fix the problem either by creating an alias for libtoolize
or by editing the single line in autogen.sh
that refers to libtoolize
to point to glibtoolize
, instead; furthermore, based on what I read here, it seems that the configuration script fails to detect the 64-bit architecture on some Macs. If this happens to you (you'll know because Apache will fail to start up), run CFLAGS="-m64" ./autogen.sh --prefix=/Library/Frameworks/Mono.framework/Versions/Current
followed by a make clean
and make
.make && make install
. Note that you will probably need elevated permission to complete the installation ste./etc/httpd/httpd.conf
and add this to the end of the file: Include /private/etc/httpd/mod_mono.conf
. Update: in Leopard, this is /etc/apache2/httpd.conf
.At this point, you should have basic support for ASP.NET on your Mac. The last step that you performed turned on Apache, which by default will look for content in /Library/WebServer/Documents, and putting aspx files ino this folder should result in them being handled by mod_mono.
It should be noted that many applications will require more advanced setup than this (for example, applications like the CruiseControl.NET web dashboard want to be able to handle all web requests for their directory, not just the ones pointing to aspx files), but this is a topic for another post.
Update: the process for building Mono has changed significantly since I first wrote this. You can view updated instructions here.
Ever since I first heard about Mono, I've been fascinated by the potential of .NET to become a viable platform for software that targets multiple OSes. Unfortunately, I've discovered (as seems to be the case with many OSS projects), the documentation aimed towards beginners is quite limited, especially when one ventures away from running Mono on Linux.
I've spent many hours trying to get my development environment for the Mac just right, and at times, it's been a rather painful process. So, in the interest of reducing the pain felt by any beginners following after me, I've decided to start recording my processes for getting things set up. At best, this blog will become a useful resource for anyone doing .NET development on the Mac. At worst...well, at least I'll be able to set things up again the next time I have to wipe a hard drive or replace a machine.
One of the first things that I've found in my work is that the Mono installer available from the Mono Project is rarely sufficient for doing any serious development work: bugs abound in the new parts of Mono (I've found a number of problems in generics), and sometimes, I simply can't resist the urge to dig in and fix them. Therefore, when setting up a new development environment, my first goal is generally to get a custom build of Mono up and running.
Here's how I do it:
Prerequisites:
The actual work:
~/src/mono
.~/src/mono
. Run the command svn checkout svn://anonsvn.mono-project.com/source/trunk/mono svn://anonsvn.mono-project.com/source/trunk/mcs
. This will download the code for the core Mono libraries and the Mono Compiler System. They'll end up in ~/src/mono/mono
and ~/src/mono/mcs
./opt/mono
.cd ~/src/mono/mono && ./autogen.sh —prefix=/opt/mono
. This step should get Mono ready to build.make && make install
. I'd love to be able to recommend that you also insert make check
in that list, but the sad fact is that Mono on MacOS actually fails a number of tests.After you've done all this, you should have a working (custom) build of Mono working on your machine. You can, at any time, upgrade to the latest code by going to ~/src/mono
and running the command svn update mono mcs
. Generally, you'll be able to jump straight to building Mono again, but you may sometimes be required to also run autogen.sh
.
Also, it's often very handy to have a script around that will set up all of your paths and whatnot to your custom build of mono. The Parallel Mono Environments page on the Mono website describes this, although I had to modify mine a bit to get it working right. Here's what it looks like now:
#!/bin/bash
MONO_PREFIX=/opt/mono
GNOME_PREFIX=/opt/gnome
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:/sw/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include:/sw/include:/Library/Frameworks/Mono.framework/Versions/1.2.2.1/include/libpng
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig:/sw/lib/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/X11R6/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/1.2.2.1/lib/pkgconfig
PATH=$MONO_PREFIX/bin:$PATH:/sw/bin
PS1="[mono] \w @ "
Mine is stored in ~/mono-dev-env
and is invoked via source ~/mono-dev-env
That's it for my first post on setting up a development environment for Mac/.NET development. In the future, I'll go into setting up mod_mono (for ASP.NET), CruiseControl.NET (you do have unit test you'd like to run regularly, don't you?), and Subversion (I realize that Subversion isn't strictly related to .NET, but I didn't have a Subversion server when I started this project, and trying to figure out how to get it set up wasn't terribly fun).
Update: Google Analytics tells me that people are coming to my blog for information about installing Subtext on GoDaddy's servers. Because I'm such a wonderful person, I'm adding instructions for how to do this. (7-4-07)
Update 2: Mikeas has posted more detailed instructions on how to modify the Web.config that comes with Subtext, including a couple of things that I had forgotten to mention (like e-mail). You can view his instructions here.
I used to be on dasBlog, but it was difficult to install onto GoDaddy's servers, and the version I was using didn't have support for ASP.NET 2.0 (which is needed for some other development that I want to do), so I switched to SubText.
With any luck, I'll actually get around to posting real content here in the future…
This wasn't originally what I had intended to blog about, but it seems to be why people are coming to my site right now, so here's how I did it. For the sake of completeness, I'm using GoDaddy's Deluxe Windows Hosting for this site, and it runs me about seven bucks a month.
A note about automatic redirecting:
For whatever reason, GoDaddy has elected to not allow you to change the ASP.Net permissions on your root folder, and 404 redirects won't work for visiting http://yourdomain.sometld/. If, like me, your blog is the primary content on your site, and this is the first thing that you'd like visitors to see, you can configure a Default.aspx that will redirect people to http://yourdomain.sometld/blog. Here's what mine looks like:
<%@ Page language="c#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head runat="server">
<title></title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<% Response.Redirect("http://www.fallingcanbedeadly.com/blog"); %>
</form>
</body>
</html>
Anyway, this is how I have my blog set up, and I would assume that it would work for most users, but I make no guarantees to this effect. Let me know how it turns out for you!