openSUSE and Apache with Mono 2.0

SneWs's picture

So, I started to try to port some of my Web services running on IIS and Windows server to Linux (openSuSE). The first problem that occurred was that mod_mono is running with version 1.1 as default, nothing strange with that, but I need support for 2.0+
So, what to do you might ask, and here is the solution that got me up and running for a quick and dirty test. It's not a optimal config, but it's good enough for testing.

First of, make sure to install the mono environment and mod-mono for Apache. When that is done, you need to create a config file for the module. As of this example, I created a mod_mono.config and included it in httpd.conf.

The mod_mono.conf file needs some basic parameters. (See complete config example below).

First up, for running with mono v.2.0 instead of 1.1, we need to point out the path to the server executable:

# Set 2.0 server for site "default"
MonoServerPath default /usr/bin/mod-mono-server2

# Let's enable auto application support as well
MonoAutoApplication enabled

Then we need to setup some basic handler and module binding for asp.net specific files.

# Point mono handler as default for the following files and content types.
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .cs

# Setup our type and handler bindings, NOTE the module is auto loaded with apache
LoadModule mono_module /usr/lib/apache2/mod_mono.so
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx .cs

Now we need to point out where to store the unix socket and where to search for config files, libraries etc.

# Set socket path
MonoUnixSocket /tmp/.mod_mono_server2

# Mono configuration path (Machine.config etc)
MonoApplicationsConfigDir /etc/mono/2.0

# Mono path for binarys (*.dll)
MonoPath /usr/lib/mono:/usr/lib/mono/1.0:/usr/lib/mono/2.0:/usr/lib/mono/2.1:/usr/lib:/usr/lib/mono/3.5

So, for the simplicity, you may just copy/past the mod_mono.config file for a quick test, don't forget to change the Alias, Directory and Location parameters.

I really hope this will help you to get started with porting / testing your asp.net or Web services on Linux.

For more information on Mono on openSuSE, please visit http://en.opensuse.org/Mono

-- My test mod_mono.config file
# This file is responsible for loading and setting default config
# for the mono module

# Setup our type and handler bindings, NOTE the module is auto loaded with apache
#LoadModule mono_module /usr/lib/apache2/mod_mono.so
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx .cs

# Specific mono settings
MonoServerPath default /usr/bin/mod-mono-server2
MonoAutoApplication enabled
MonoUnixSocket /tmp/.mod_mono_server2
MonoApplicationsConfigDir /etc/mono/2.0
MonoPath /usr/lib/mono:/usr/lib/mono/1.0:/usr/lib/mono/2.0:/usr/lib/mono/2.1:/usr/lib:/usr/lib/mono/3.5

# Setup our mono control panel by default

SetHandler mono-ctrl
Order deny,allow
Deny from all
Allow from 127.0.0.1

Alias /service-point "/var/lib/www/services"
AddMonoApplications default "/service-point:/var/lib/www/services"

Options Indexes FollowSymLinks
Order allow,deny
allow from all

SetHandler mono

Post new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
© 2008 - 2017 Marcus Grenängen. Drupal theme by Kiwi Themes.