2008-11-19

Mono Installation Steps on CentOS

Mono provides the necessary software to develop and run .NET client
and server applications on Linux, Solaris, Mac OS X, Windows, and Unix.

To run the ASP.NET applications with Mono, there are three components of mono we need install:
  • Mono is the core module.
  • XSP is a simple way to get started, a lightweight and simple webserver written in C#.
  • Mod_Mono is an Apache 1.3/2.0/2.2 module that provides ASP.NET support for the web's favorite server.

There are three basic steps of mono installation:
  • Install the mono software;
  • Configure the mono service together with Apache;
  • Restart Apache.

The details of installation are discussed below:


1. Install the mono

The prefered method for installing Mono on RedHat/CentOS is to use yum.

Log onto your server;

Use vi to create a file named mono.repo and save it in /etc/yum.repos.d will allow you to install mono and related packages.

    [mono]
name=Mono for rhel-4-i386 (stable)
baseurl=http://ftp.novell.com/pub/mono/download-stable/rhel-4-i386/
enabled=1
gpgcheck=0

Then, use yum to install mono and xsp package:

    #sudo yum install mono
#sudo yum install xsp
#sudo yum install mod_mono

Note:

Currently, the packed mod_mono is not running smooth on x86-64. So we install it from source, instead of installation by yum.

Download the source code (mod_mono-1.9.tar.bz2) from http://go-mono.com/sources-stable/

Place the download file to /tmp and unpack it to /usr/local (or other directory you like):


    #cd /usr/local
#tar jxvf /tmp/mod_mono-1.9.tar.bz2

Compile the source code:


    #cd /usr/local/mod_mono-1.9
#./configure --with-apxs=/usr/sbin/apxs
#make
#make install

2. Configure the mono together with Apache


To run ASP.NET applications within the Apache, we need apache, the web server, installed. So, we can publish the mono service on web site though Apache.

After install the mono, you can find a default configure file name mod_mono.conf in mono's directory(In this instance, it is /etc/mono/conf.d/mod_mono.conf). mod_mono.conf loads the mod_mono module, associates ASP.NET file extensions with the ASP.NET MIME type and adds index.aspx, Default.aspx, and default.aspx as automatic directory index pages.

To load the mod_mono, add 1 line in the Apache configuration file like this:

    Include /etc/mono/conf.d/mod_mono.conf

Now, we need edit the mod_mono.conf file to meet our special needs. As example, we publish the mono's build in test files, add these lines at the end of mod_mono.conf:

    #This is the mono's examples
Alias /mono_test "/usr/lib/xsp/test"
MonoApplications "/mono_test:/usr/lib/xsp/test"
MonoServerPath "/usr/bin/mod-mono-server2"
<Location /mono_test>
SetHandler mono
</Location>

#This is the controller of mono
<Location /mono>
SetHandler mono-ctrl
Order deny,allow
Deny from all
Allow from 192.168.1.0/24
</Location>

Run the following command to check the configurations:

    #httpd -t

Syntax OK

3. Restart Apache

Restart Apache to start mono web service by the following command:

    #service httpd restart

Stopping httpd: [ OK ]
Starting httpd: [ OK ]

Now, the mono project it is available on web with this address:

    http://localhost/mono_test

If you are new to mono, get start with the The sample of writing code using mono on Linux, and have a look at the examples.


Further information about mono can be found at mono's website: http://www.mono-project.com/Mod_mono




No comments:

Post a Comment