The first step is optional, but assumed throughout the rest of this guide for the sake of brevity;
$ sudo -s
First we'll need to install some prerequisites
$ apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libfontconfig1-dev
$ apt-get install libx11-dev
$ apt-get install libexif-dev libgif-dev libjpeg-dev libpng12-dev libtiff4-dev
$ apt-get install mono-gmcs
$ apt-get install apache2-threaded-dev
Once the necessary prerequisites have been installed, we need to grab the source packages.
Let's download and extract them under /opt
$ mkdir /opt/mono-3.2
$ cd /opt/mono-3.2
$ wget http://download.pokorra.de/mono/tarballs/mono-3.2.5.tar.bz2
$ wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.tar.bz2
$ wget http://download.mono-project.com/sources/xsp/xsp-2.10.tar.bz2
$ wget http://download.mono-project.com/sources/mod_mono/mod_mono-2.10.tar.bz2
Extract them all using something similar to this
$ tar xjf <filename>
Once all the source packages have been downloaded and extracted, let's begin compiling
$ cd /opt/mono-3.2/libgdiplus-2.10/
$ ./configure --prefix=/usr
$ make
$ make install
$ cd /opt/mono-3.2/mono-3.2.5/
$ ./configure --prefix=/usr
$ make
$ make install
$ cd /opt/mono-3.2/xsp-2.10/
$ ./configure --prefix=/usr
$ make
$ make install
$ cd /opt/mono-3.2/mod_mono-2.10/
$ ./configure --prefix=/usr
$ make
$ make install
Assuming everything installed correctly, we can no begin configuring apache2 and mod_mono.
In order to be able to use apache's module management utils, we'll have to move the default mod_mono.conf file, and create a .load file
$ mv /etc/apache2/mod_mono.conf /etc/apache2/mods-available/mono.conf
$ echo "LoadModule mono_module /usr/lib/apache2/modules/mod_mono.so" > /etc/apache2/mods-available/mono.load
mod_mono can now be enabled and disabled by using $ a2enmod monoand $ a2dismod mono,
respectively, but before we do that, we'll have to copy a few files
(because mod_mono is out of sync with Mono)
$ cp /usr/lib/mono/4.0/fastcgi-mono-server4.exe /usr/lib/mono/4.5/
$ cp /usr/lib/mono/4.0/mod-mono-server4.exe /usr/lib/mono/4.5/
$ cp /usr/lib/mono/4.0/xsp4.exe /usr/lib/mono/4.5/
In addition, we'll have to change the path in the default shim /usr/bin/mod-mono-server4 using nano
or whatever text editor you prefer. It should look like this after you've edited it:
#!/bin/sh
exec /usr/bin/mono $MONO_OPTIONS "/usr/lib/mono/4.5/mod-mono-server4.exe" "$@"
Now we need to make sure mod_mono targets the right framework version, and has the correct
handler, and so on; edit /etc/apache2/mods-available/mono.conf until it looks like this:
# mod_mono.conf
<IfModule mod_headers.c>
Header set X-Powered-By "Mono"
</IfModule>
MonoAutoApplication disabled
AddHandler mono .aspx .ascx .asax .ashx .config .cs .asmx .axd
MonoServerPath default "/usr/bin/mod-mono-server4"
AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .vb
AddType application/x-asp-net .master
AddType application/x-asp-net .sitemap
AddType application/x-asp-net .resources
AddType application/x-asp-net .skin
AddType application/x-asp-net .browser
AddType application/x-asp-net .webinfo
AddType application/x-asp-net .resx
AddType application/x-asp-net .licx
AddType application/x-asp-net .csproj
AddType application/x-asp-net .vbproj
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx
Now we can enabled mod_mono and restart apache
$ a2enmod mono
$ apachectl restart
The simplest possible configuration of an apache site, should
contain something like this inside of a <VirtualHost>..</VirtualHost>
block or similar
AddMonoApplications default "/:/var/www/dcpvalidator"
MonoServerPath default "/usr/bin/mod-mono-server4"
<Location />
SetHandler mono
</Location>
This enables the mono handler we configured in /etc/apache2/mods-available/mono.conf
earlier.