Software
Website Portfolio
Resume
Wiki
Blog
Contact

Archives

  • October 2010
  • June 2010
  • December 2008
  • February 2008
  • March 2007
  • December 2006
  • November 2006
  • September 2006

Meta

  • Log in

Hosting ASP.NET 2.0 Applications on Ubuntu 10.04 LTS using Apache & mod_mono

Posted on June 13th, 2010

Being a .NET developer by trade, I’ve got several web applications written in ASP.NET that I’d like to host. Currently, I have hosting with Rackspace Cloud, and pay per hour based on the resources I’m allocating. I toyed with deploying a 2nd VM running windows, but the price was a bit steep for the kind of hobbyist activities I’m doing here. I figured I’d check to see how ASP.NET hosting on Apache has evolved over the years. I’ve concluded that it seems like it’s fairly stable now, and relatively easy to get running. This tutorial will help you deploy virtual hosting with mod_mono on Ubuntu 10.04 LTS.

Firstly, you’ll need to install mod_mono

$ sudo apt-get install mod_mono

Next, enable mod_mono

$ sudo a2enmod mod_mono

We’ll need to change the default index a bit to match up more closely with an IIS environment.
You’ll need to edit /etc/apache2/mods-enabled/mod_mono.conf

Change this (Line 2):

DirectoryIndex index.aspx

To this:

DirectoryIndex Default.aspx index.aspx

Next, we create our site.
Edit /etc/apache2/sites-available/YOUR-SITE-URL and use the following template:
Note: Replace YOUR-SITE-URL and /var/www/mysite with values appropriate for your configuration

<VirtualHost *:80>
        ServerName YOUR-SITE-URL
 
        DocumentRoot /var/www/mysite/
 
        MonoDocumentRootDir "/var/www/mysite"
        MonoServerPath monosite "/usr/bin/mod-mono-server2"
        MonoApplications monosite "/:/var/www/mysite"
 
        <Directory /var/www/mysite/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
                MonoSetServerAlias monosite
                SetHandler mono
        </Directory>
</VirtualHost>

Next, you’ll need to enable the site and reload Apache:
Note: Replace YOUR-SITE-URL with the same value you used above

$ sudo a2ensite YOUR-SITE-URL
$ sudo /etc/init.d/apache2 reload

Next, we’ll test it out.

Edit /var/www/YOUR-SITE-URL/Default.aspx and paste the following:
Note: Replace YOUR-SITE-URL with the same value you used above

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>ASP Test Page</title>
  </head>
  <body>
        <form id="form1" runat="server">
          <asp:label id="lbl1" runat="server">ASP Test Page</asp:label>
        </form>
  </body>
</html>

Now visit your site in your browser. http://YOUR-SITE-URL

It should be working at this point.

Good luck!

Site content and design copyright 2005-2010 bsd.bz