February 26, 2015

Apache and mod_mono on rasbian

Mod_mono is much easier to config at the moment than it has been int he past.  Assuming you can use apt-get and installed the packages the following is all you need.

apt-get install libapache2-mod-mono mono-apache-server2

Once installed you need to configure for automatic operations.  Make sure the /etc/apache2/mods-enabled directory contains both of your entries for the load and config of mod mono.


AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascxDirectoryIndex Default.aspx index.aspx
# Include the web application definitions generated by mono-server{2,4}-update.## If you want to use ASP.NET 2.0 (via mono-apache-server2), use:# Include /etc/mono-server2/mono-server2-hosts.conf## If you want to use ASP.NET 4.0 (via mono-apache-server4), use:# Include /etc/mono-server4/mono-server4-hosts.conf
Include /etc/mono-server2/mono-server2-hosts.conf
<Location /mono>  SetHandler mono-ctrl  Order deny,allow  Deny from all  Allow from 192.168.200</Location>


LoadModule mono_module /usr/lib/apache2/modules/mod_mono.so

Next check your /etc/apache2/sites-enabled/000-default file.  Apache is preconfigured with virtual hosting and you need to enable mod_mono for each virtual site.  You do that by adding the following directive and value: MonoAutoApplication enabled.


<VirtualHost *:80>ServerAdmin webmaster@localhostDocumentRoot /var/wwwMonoAutoApplication enabled<Directory />Options FollowSymLinksAllowOverride None</Directory><Directory /var/www/>Options Indexes FollowSymLinks MultiViewsAllowOverride NoneOrder allow,denyallow from all</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/<Directory "/usr/lib/cgi-bin">AllowOverride NoneOptions +ExecCGI -MultiViews +SymLinksIfOwnerMatchOrder allow,denyAllow from all</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,# alert, emerg.LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>

Next you need to check your /etc/mono-server2/mono-server2-hosts.conf file and make sure it has the MonoAutoApplication directive set to enabled.  Your file should look like this.

<IfModule mod_mono.c>
ForceType application/x-asp-net
MonoAutoApplication enabled
MonoUnixSocket default /tmp/.mod_mono_server2
MonoServerPath default /usr/bin/mod-mono-server2
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .svc .ascx
MonoApplicationsConfigDir default /etc/mono-server2
MonoPath default /usr/lib/mono/2.0:/usr/lib

After this a quick restart of apache should have you with a working mono setup.  If you have issues with applications running you may need to enable the registry hive.  The following should be run in the root area where your web.con file is located for the application.

mkdir .mono
chown -R www-data.www-data .mono

This will create the directory and assign permissions for it under a default rasbian setup.  Finally working .net on the raspberry pi computer, I’ve had luck with everything from winforms to wcf services with the raspy2.

Leave a comment

You must be logged in to post a comment.