Showing posts with label Mono. Show all posts
Showing posts with label Mono. Show all posts

Friday, 28 November 2008

Apache, Mono and Virtual Hosts

I run some ASP.Net applications under mono on a Debian host. Mono has come a long way in the last few years and is now making progress in support for C# 3.0 and even WCF. This adds appeal to the platform and increases the scope of it's usefullness.


One thing I had trouble finding documentation for and ended up accomplishing through trial and error was setting up my Mono applications to run in an Apache (2) Virtual Host. The most difficult bit turned out to be the configuration of my sites-available file in /etc/apache2/sites-available. So I've decided to share it here:


<VirtualHost *>
ServerName example.com
ServerAlias www.example.com example.net www.example.net example.co.uk www.example.co.uk
DocumentRoot /var/www/example.com
ServerAdmin serveradmin@example.com
ErrorLog /var/log/apache2/example.com-error_log
#RewriteEngine on
#RewriteRule ^/([A-Za-z]*)/?$ /?Page=$1 [PT]
AddMonoApplications example "/:/var/www/example.com"
MonoUnixSocket example /tmp/.example_mod_mono_server2
MonoServerPath example /usr/lib/mono/2.0/mod-mono-server2.exe
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx .svc
MonoApplicationsConfigDir example /etc/mono-server2
MonoPath example /usr/lib/mono/2.0:/usr/lib:/usr/lib/mono/2.0
<Directory "/var/www/example.com">
MonoSetServerAlias example
SetHandler mono
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

As you can see, I have commented out the RewriteEngine and RewriteRule directives but there is enough there for you to see what new tricks we .Net devs have to play with when we write code for a Mono deployment...

Saturday, 9 June 2007

Mono is maturing!

I have a simple .Net 2.0 project on the go at the moment that uses a web application project, a web service application project, the MySql connector and some C# class libraries that take advantage of generics. I decided to give MonoDevelop another whirl and have been pleasantly surprised with the results.

Importing the sln and csproj files works but you lose the debug automation. It's just a case of some missing lines in the project files but I opted to create a blank mds solution and associated mdp projects using the MonoDevelop templates. The result is that running a debug fires up xsp2 so that you can see your web and web service output.

There's a minor glitch in mono-xsp2 for Debian and Ubuntu where the preinstall script run by the package manager barfs on a syntax error. I had to open up the deb and fix the script, repackage and reinstall with dpkg. I would upload my fixed deb, but I reckon it'll be fixed upstream before anyone else notices. I found the information to do this at these url's: maebmij.org/~jim/ synthesize.us

The result of this bit of phaffing is that it's rather simple to create multi platform web projects in .Net without a great deal of dependency installs. Yay for mono!

The code and solutions I've mentioned here are available at: http://code.google.com/p/nimble/

Sunday, 29 April 2007

MonoDevelop

I want to use mono for a hobby CMS project I'm working on because I intend to open source the product and I'd like for it to be compatible with Linux hosting. MonoDevelop has made slow but steady progress over the couple of years I've been downloading it and abandoning the projects I create with it. But the 0.13.1 release has actually made the platform useable for me. The ASP.Net implementation can handle Web Application Projects with Generics, Serialization, Web Services and lots of the other tricks VS 2005 users take for granted.

I shall update this post as OpenShowCase evolves and highlight the adequacies and inadequacies of the Mono platform for a developer thats used to having all the toys.

I work off several development machines depending on whether I'm on my lunch hour, at home or in a hotel so I need both the IDE and source to be available wherever I am. My laptop runs Ubuntu and my PC at home runs Debian so I just added Mirco Bauers Debian repository to both apt sources (deb http://debian.meebey.net/ ./).

As it's a non-standard repository you also need Mirco's PGP key:
gpg --keyserver hkp://wwwkeys.eu.pgp.net --recv-keys 0x7127E5ABEEF946C8
gpg --export -a 0x7127E5ABEEF946C8 | apt-key add -
apt-get update && apt-get install monodevelop monodevelop-versioncontrol kdesvn
I haven't tried to get MonoDevelop working on Windows yet but I'll update this when I have.

For source control I've used subversion and taken advantage of Google's code and project hosting. The version control plugin for MonoDevelop works well but has a problem with adding a newly created solution to an existing repository. The same problem appears to affect kdesvn so the simplest thing to do is just create the code.google.com repository and use the command line client to make the first commit. From the console change to the directory that you keep all your projects in and enter the command below:
svn checkout https://.googlecode.com/svn/trunk/ openshowcase --username 
Afterwards the plugin seems to work fine.