Category Archives: Linux

Mono and ISPConfig 3

We use Linux quite a bit. Mono is  a great tool if your app is built to run on it. Installing it is easy enough (yum install mod_mono, a2enable mod_mono, etc..) but you have to take 2 additional steps to enable it on each website before it actually works.

As an admin user in ISPConfig, go to the site and the “Options” tab. In the Apache Directives paste in the following code (replace website.com with the name of your site).

MonoAutoApplication enabled
 MonoDocumentRootDir "/var/www/website.com/web/"
 MonoServerPath example "/usr/bin/mod-mono-server4"
 MonoApplications website "/:/var/www/website.com/web/"
 Alias /mono "/var/www/website.com/web/"
 <Directory /var/www/website.com/web/>
 SetHandler mono
 MonoSetServerAlias website
 AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
 </Directory>

After that, make sure to change the ownership of the web folder to www-data (or whatever username your apache web service is running under) .

chown -R www-data /var/www/website.com/web

Once you turn this on, throw an ASPX page in the folder and try it out.

If you have a problem you can look for errors here:

tail /var/log/apache2/error.log

Be aware that turning this on will mess with other scripts specifically PHP.

Written by: Ray Pulsipher

Khan academy offline (KALite) – Run on port 80

KALite is a great tool if you want to bring the resources available to an offline environment.

We run a virtual server with KALite. We point a DNS name at it an everything, but we don’t like that it runs on port 8008 rather than port 80.  Here is a recipe to make it work on a Debian 7 server without having to change configuration of the KALite script.

Problem: You can change KALite to run on port 80, but you have to run it as the root user, which it doesn’t want to do.

Solution: The firewall can automatically forward all traffic from port 80 to port 8008. KALite doesn’t know anything has changed.

Step 1 – Create a file on the debian server: 

nano /etc/network/if-pre-up.d/iptables

Step 2 – In that file paste this code:

#!/bin/sh
#Redirect all traffic from port 80 to port 8008
# (khan port)
iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8008

NOTE: The iptables command wraps here and it should be all one line when you paste it.

Step 3 – Chown file so it is owned by root:

chown root:root /etc/network/if-pre-up.d/iptables

Step 4 – Chmod file so it can be run:

chmod +x /etc/network/if-pre-up.d/iptables

Step 5 – Reboot:

Assuming you have KALite starting on reboot, you should be able to access it without the :8008 at the end now.

Written By: Ray Pulsipher