You are interested in the development of WCF Web Services but you don’t how to host it?
One of the solution is, of course, a Windows Server with IIS but there is a cheaper alternative, Mono.
Mono is a free Open Source implementation of Microsoft .NET platform, and it can be run on a Linux/GNU based machine.
The installation of Mono is not difficult and it can be easily hosted by an Apache web server.
The installation has been tested on Debian 5.0.4 and Ubuntu 10.10 with Apache 2.2.9 and Mono 2.6.7
Note that the current Mono version does not support all the .NET 4.0 functionnalities.
So take care to use .NET 3.5 or check your project compatibility with MoMA, a tool provided by Mono team.
Install the Mono packages
The simplest part. Install the required Mono packages.
sudo apt-get install mono-apache-server2 libapache2-mod-mono mono-gmcs mono-utils
Configure Apache Virtual host:
You can use the existant virtual host files but I think it’s better to dedicate one to the Mono applications.
Create a file under the path: /etc/apache2/sites-available/mono.youdomain.com
With the following content:
# You can use another port, like 443 if SSL is installed <VirtualHost *:80> # mono configuration # "example.braincast.com" can be replaced by anything you want, it's just an id MonoServerPath example.braincast.com "/usr/bin/mod-mono-server2" MonoDebug example.braincast.com false MonoSetEnv example.braincast.com MONO_IOMAP=all MonoAutoApplication disabled # Define application name and path MonoApplications example.braincast.com "/first:/var/www/firstapp" <Location /first> Allow from all MonoSetServerAlias example.braincast.com SetHandler mono Order allow,deny </Location> </VirtualHost>
Then, it can be enabled in Apache:
This configuration will allow the access to the app located in /var/www/firstapp under the url http://yourdomain.com/first/yourservice.svc
In the file /etc/apache2/mods-available/mod_mono.conf, set the configuration as following:
AddType application/x-asp-net .svc .aspx .ashx .asmx .ascx .asax .config DirectoryIndex index.aspx Include /etc/mono-server2/mono-server2-hosts.conf
Active the Apache Mono Mod
That’s all, you should be able to test your service.
If the server returns an error 404, try to unload the default site configuration and then, restart Apache.
It’s possible that this configuration overrides yours.
Of course, you can also try to edit the default configuration instead of disabled it.
The configuration has been tested on Debian and Ubuntu.
I suppose that the commands are not exactly the same on the others distributions but it can help