Mono: ASP.NET with Apache & Linux
ASP.Net is Microsoft's platform for developing Web applications. Until recently every ASP.Net application was executable only under a same Microsoft-developed runtime environment and its Internet Information Server Web server. In late June Novell released the first major version of Mono, an open source implementation of the .Net framework that lets you execute .Net applications on Linux and the Apache Web server. Here's how you can begin using Mono and its ancillary tools XSP and mod_mono.
To get started you need to download three distinct packages: The Mono Runtime, XSP Web server, and the Apache Mono Module (mod_mono), all of which are available from the Mono Project . Besides these packages you obviously also need to have an Apache Web server installed, from either the 1.x or 2.x branch.
Your first step should be installing the Mono runtime. It's the central piece for executing .Net applications, since it contains a Common Intermediate Language virtual machine for interpreting .Net byte-code, the class loader, garbage collector, threading system, and metadata access libraries. Its role is similar in nature to that of the JDK and JRE in Java applications. If you opted to download the source code tarball, make sure you have both pkg-config and glib 2.0 installed on your system, as you need them both to build Mono. If you decided to download a specific RPM, consult the dependencies as required by your distribution.
Although the Mono runtime is a central part of running .Net applications on Linux, it's the XSP Web server that provides the main functionalities for executing ASP.Net components, given its implementation of the System.Web classes needed to execute ASP.Net code. You can run XSP either standalone or in conjunction with Apache. The architecture selection for running XSP in either mode depends heavily on the type of traffic and the load you expect for any given application. If you are familiar with deploying Java applications, this selection is similar in nature to bridging Apache with a Java application server or running it standalone.
Proceed with the installation of the XSP Web server. With the source code tarball you need to execute the standard configure, make, and make install commands while in the main directory of the distribution to install XSP, assuming the Mono runtime was installed under the default directory /usr/local/. If this is not the case, you will need to pass the --prefix=<Mono_root_dir> flag to the ./configure command.
Once you have installed the XSP Web server, you can proceed to the final step, which is installing the mod_mono module used to integrate Apache with Mono and XSP. The installation for mod_mono requires the same steps previously outlined for the XSP Web server, assuming you have been using a default setup and your Apache Web server is installed under the typical /usr/local/apache directory. When you execute the installation steps for mod_mono, the shared module libmod_mono.so will be placed under the modules directory if you are using Apache 2.x, or under libexec in case you use Apache 1.x.
Once mod_mono is installed, you can proceed with the Apache-specific configuration. The following snippet represents the Mono configuration in the httpd.conf file for an Apache 2.x Web server:
LoadModule mono_module modules/libmod_mono.so Alias /aspnet "/usr/share/doc/xsp/test" MonoApplications "/aspnet:/usr/share/doc/xsp/test" <Directory /usr/share/doc/xsp/test> SetHandler mono </Directory>
The first line indicates the loading of the Apache mono module libmod_mono.so. The Alias line specifies that a request under /aspnet without a trailing slash be mapped to files under the /usr/share/doc/xsp/test directory of the file system, where this last location represents a directory created by the XSP server containing a series of ASP.Net examples.
The MonoApplications directive indicates that all requests to /aspnet:/usr/share/doc/xsp/test be processed by Mono/XSP, while the <Directory> element specifies that every file under /usr/share/doc/xsp/test -- regardless of its extension -- will also be processed by Mono/XSP. This last parameter may be adjusted to redirect only ASP.Net files to Mono/XSP and leave all others under the control of Apache, but for practical purposes every file will be processed by Mono/XSP.
Following this procedure gives you the most basic configuration profile needed to deploy ASP.Net applications under an alternate infrastructure to that offered by Microsoft. Even though Mono was only recently released and has yet to incorporate some advanced features offered by its Microsoft counterpart, it offers a viable alternative to deploying .Net applications on existing production systems using Linux and the Apache Web server, guaranteeing the robustness and stability of the aforementioned platforms.