Home Linux Servers Run ASP.NET From Linux Apache Server Using Mono

Run ASP.NET From Linux Apache Server Using Mono
Written by Kwok Yao Chim   
Wednesday, 05 March 2008 00:31
 
I found this great software platform a few years ago where it will allow .NET applications to be run on cross-platform environments.

This software is called Mono, the project describes itself as:

"Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix. Sponsored by Novell (http://www.novell.com), the Mono open source project has an active and enthusiastic contributing community and is positioned to become the leading choice for development of Linux applications."

The Mono Project can be found at www.mono-project.com, and it has all the necessary background on the amount of component support and the files, manual and how-to so that you can get started.

Here's how I implemented Mono into my Apache server to allow me to run ASP.NET applications...


Step 1 - Installing Mono

Most of my Linux installations and setup is based heavily on CentOS purely because of the ease of installing via YUM and guess what... Yes, thats right, Mono Project do have a yum repository, heres what you need to do:

$ cd /etc/yum.repos.d/
$ vi mono.repos


In the mono.repos fill with the following details:

[mono]
name=Mono for rhel-4-i386 (stable)
baseurl=http://go-mono.com/download-stable/rhel-4-i386/
enabled=1
gpgcheck=0
(note: you can put these details into a current *.repos file if you don't want to create a new repos file.)

Make sure that the CentOS-Extras repos is not enabled.
Make sure CentOS-Plus repos is enabled as you may need to resolve some dependency errors.

See if you can connect to the mono.repos
$ yum list mono*

It should return with a list of packages from the mono repos.

In order for Mono to work with Apache, the Mono Project website states that you will need the mono core files, mod_mono and xsp.

The mono-core files as the name suggests is the underlying framework that allows .NET apps to run.
XSP is a light weight web server application, and mod_mono is the module plugin for Apache that helps it make use of XSP.

Install the mono-core files:
$ yum install mono-core

you may get the following dependency errors:
...
libICE.so.9 is required by libgdiplus
..
..
libexif.so.9 is required by libgdiplus
...

If you do get these errors, especially libexif.so.9, install the libgdiplus-devel this will cause the libgdiplus to install as part of dependency.
$ yum install libgdiplus-devel

After successfully installing libgdiplus we can now go ahead and install mono-core, xsp and mod_mono
$ yum install mono-core xsp mod_mono


It should also resolve some dependencies too.

Step 2 - Configuring Apache and mod_mono

Fortunately Mono makes it easy for us to use the mod_mono in Apache, all one has to do is add this line into the httpd.conf file:
Include /etc/apache2/mod_mono.conf
Where apache2 is the installation of your Apache, typically httpd on CentOS systems. This will enable AutoHosting.

Be aware that during mod_mono installation, the mod_mono.conf may have been installed elsewhere. On my system it was place in /conf.d/ at the very root of the OS system.