Call us! 888.519.8529 (free) | Home | Services | About | Contact | Français

Upgrading Mono ASP.Net

September 16, 2008

This week we upgraded our equipment with a new desktop computer running  Ubuntu 8.04 "the Hardy Heron". We encountered a few issues when trying to move over websites under development in Mono ASP.Net.

We copied over the entries in /etc/apache2/apache2.conf and expected everthing to work as it did before since we had installed everything with synaptic (MySQL, Mono etc). But to our surprise, we received this generic error page:

Service Temporarily Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.2.8 (Ubuntu) mod_mono/1.2.5 Server at BasicTest Port 80


We inspected the general apache log file to see find the source of the problem:

 vim /var/log/apache2/error.log


The file contained the following error:


[Mon Sep 15 15:54:13 2008] [error] Failed running '/usr/lib/mono/2.0/mod-mono-server2.exe --filename /tmp/mod_mono_server_BasicTest --applications /:/home/developper/MonoDevelop Projects/BasicTest --nonstop --root /home/developper/MonoDevelop Projects/BasicTest (null) (null) (null) (null) (null)'. Reason: Exec format error

We had never seen that error before with mono, so we googled it and people were saying that it was an issue regarding the mapping of .exe to mono, but the simplest way was simply to remove the trailing .exe from the MonoPath directive in the apache configuration file (more on this later). So we did, and received this error:

[Mon Sep 15 16:24:31 2008] [error] Failed running '/usr/lib/mono/2.0/mod-mono-server2 --filename /tmp/mod_mono_server_BasicTest --applications /:/home/developper/MonoDevelop Projects/BasicTest/BasicTest --nonstop --root /home/developper/MonoDevelop Projects/BasicTest/BasicTest (null) (null) (null) (null) (null)'. Reason: No such file or directory

Blindly removing the exe did not resolve the problem, since that executable is actually located in /usr/bin/mod-mono-server2. Therefore, the complete section in apache.conf for a proper mono configuration is as follows:

<VirtualHost *:80>
    ServerName BasicTest
    DocumentRoot "/home/developper/MonoDevelop Projects/BasicTest/BasicTest"
    MonoApplications BasicTest  "/:/home/developper/MonoDevelop Projects/BasicTest/BasicTest"
    MonoDocumentRootDir "/home/developper/MonoDevelop Projects/BasicTest/BasicTest"
    MonoServerPath BasicTest /usr/bin/mod-mono-server2
    MonoDebug true
   <Location />
      MonoSetServerAlias BasicTest
      SetHandler mono
   </Location>
   ErrorLog /var/log/apache2/basictest.error.log
   CustomLog /var/log/apache2/basictest.access.log combined
</VirtualHost>

The crucial line was bolded. Now as long as you have an entry in your /etc/hosts file, you can access this local site via http://BasicTest

Hopefully this tutorial was of assistance to someone, let us know.

 


 

This doesn't apply to our configuration, but may affect others so we'll include it for completion. In your mod_mono conf:

 

sudo vim /etc/apache2/mods-enabled/mod_mono.conf



You should see two lines like these.

 

#Include /etc/mono-server/mono-server-hosts.conf
Include /etc/mono-server2/mono-server2-hosts.conf


If you want to use Mono ASP.Net 2.0 (like we do), the second line should be uncommented. Now edit the file in question:

 

sudo vim /etc/mono-server2/mono-server2-hosts.conf

 

And change

MonoServerPath default /usr/lib/mono/2.0/mod-mono-server2.exe

to

MonoServerPath default /usr/bin/mod-mono-server2

© Copyright 2009 Abludo Web Design