Setting Up Mono and mod_mono in Plesk 8.6

Mono is the the open-source version of the Microsoft’s .NET runtime. Mono runs on Linux, Unix, BSD, Solaris, and Windows. Mod_mono and XSP are Mono components that bring ASP.NET functionality to non-Microsoft servers.  For an example of an ASP.NET page running, in Mono, check out Hello World, 2!

Getting Mono up and running in a Plesk system is suprisingly easy. I use CentOS, which is a Fedora-based system. Consequently, these instructions are geared toward CentOS Plesk systems. However, with the exception of steps 1 and 2, these instructions should work for any Linux-based Plesk system.

0) SSH into your server.

1) Add the Mono repository to your yum repositories.

In CentOS, yum stores a list of its repositories in /etc/yum.repos.d, so adding the Mono repository is as easy as downloading the mono.repo file to this directory.

cd /etc/yum.repos.d/
wget http://ftp.novell.com/pub/mono/download-stable/rhel-4-i386/mono.repo

2) Install Mono, XSP, and mod_mono.

yum install mono
yum install xsp
yum install mod_mono

3) Configure Apache to use mod_mono.

Switch to the httpd customized configuration directory. In most Plesk systems, this should be located at /etc/httpd/conf.d.

cd /etc/httpd/conf.d
vi mod_mono.conf

In vi, or your favorite command line editor, paste the following:

<IfModule !mod_mono.c>
LoadModule mono_module modules/mod_mono.soAddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx
</IfModule>

Save the file.

4) Restart Apache

From your Plesk control panel, go to the Server>Services page. Restart the Web Server (Apache). You can also restart Apache from the command line.

/usr/local/psa/admin/sbin/websrvmng -a
/usr/local/psa/admin/sbin/websrvmng –restart

5) Wait a few minutes.

Plesk doesn’t restart immediatly, despite what the Plesk control panel (or the command prompt) may tell you.

6) Create a test ASP.Net page

<%@ Page Language=“C#” %>
<html>
<script language=”C#” runat=”server”>
void Page_Load(object sender, EventArgs e)
{
Response.Write(“<br>Hello World! (Response.Write)<br>”);
lbHelloWorld.Text = “Hello World! (HTML element changed.)”;
}
</script>
<body>
<asp:label id=”lbHelloWorld” runat=”server” />
</body>
</html>

7) That’s it!

    Some caveats:

  • The default configuration for mod_mono uses the Mono binaries compatible with .Net 1.1. These binaries don’t support VB.
  • Mod_mono is slow. It does not yet support pre-compiled binaries.

Leave a comment