Being a .NET developer by trade, I’ve got several web applications written in ASP.NET that I’d like to host. Currently, I have hosting with Rackspace Cloud, and pay per hour based on the resources I’m allocating. I toyed with deploying a 2nd VM running windows, but the price was a bit steep for the kind of hobbyist activities I’m doing here. I figured I’d check to see how ASP.NET hosting on Apache has evolved over the years. I’ve concluded that it seems like it’s fairly stable now, and relatively easy to get running. This tutorial will help you deploy virtual hosting with mod_mono on Ubuntu 10.04 LTS.
Firstly, you’ll need to install mod_mono
$ sudo apt-get install mod_mono
Next, enable mod_mono
$ sudo a2enmod mod_monoWe’ll need to change the default index a bit to match up more closely with an IIS environment.
You’ll need to edit /etc/apache2/mods-enabled/mod_mono.conf
Change this (Line 2):
DirectoryIndex index.aspx
To this:
DirectoryIndex Default.aspx index.aspx
Next, we create our site.
Edit /etc/apache2/sites-available/YOUR-SITE-URL and use the following template:
Note: Replace YOUR-SITE-URL and /var/www/mysite with values appropriate for your configuration
<VirtualHost *:80> ServerName YOUR-SITE-URL DocumentRoot /var/www/mysite/ MonoDocumentRootDir "/var/www/mysite" MonoServerPath monosite "/usr/bin/mod-mono-server2" MonoApplications monosite "/:/var/www/mysite" <Directory /var/www/mysite/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all MonoSetServerAlias monosite SetHandler mono </Directory> </VirtualHost>
Next, you’ll need to enable the site and reload Apache:
Note: Replace YOUR-SITE-URL with the same value you used above
$ sudo a2ensite YOUR-SITE-URL $ sudo /etc/init.d/apache2 reload
Next, we’ll test it out.
Edit /var/www/YOUR-SITE-URL/Default.aspx and paste the following:
Note: Replace YOUR-SITE-URL with the same value you used above
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>ASP Test Page</title> </head> <body> <form id="form1" runat="server"> <asp:label id="lbl1" runat="server">ASP Test Page</asp:label> </form> </body> </html>
Now visit your site in your browser. http://YOUR-SITE-URL
It should be working at this point.
Good luck!
I run mindtouch as my wiki software. It’s been a great piece of software, and I will continue running it until I can find something better. Recently, I’ve been working to overhaul all the bsd.bz sites, and bring them under one umbrella (same theme, unified header). In an effort to better develop changes to the wiki’s theme, I need to run that software locally on my dev machine (my macbook pro).
So, without further delay, this is how I got MindTouch Core v.9.12.2 installed under Snow Leopard (OSX 10.6).
This tutorial assumes you already have PHP & Apache working.
First, we’ll need to install some pre-requisite software. I’ve included direct links the the current versions of the software for your convenience. I make no guarantee these links will work in the future, but have included links to the respective download location.
Mac Ports (Currently 1.8.2) – [ Direct DL ]
MySQL (Currently 5.1.47) – [ Direct DL (Intel x86_64) ]
Mono (Currently 2.6.4) – [ Direct DL (Intel) ]
Update your hosts file.
I use wiki.localdomain so I can add other name based virtual hosts and have my mini-production replica on my dev machine. ie blog.localdomain, wiki.localdomain, etc
Open up /etc/hosts in your favorite editor (I use vi)
$ sudo vi /etc/hosts
Add this line:
127.0.0.1 wiki.localdomain
Next, we’ll need to install the pre-requisites required to run Mindtouch, and html2ps
$ sudo port selfupdate $ sudo port sync $ sudo port install ImageMagick $ sudo port install clucene $ sudo port install p5-libwww-perl $ sudo port install texlive $ sudo port install netpbm $ sudo port install wget
Now, we have enough to install html2ps. Run the installer, and choose “/opt/local” for the install path:
$ cd ~/Downloads $ wget http://user.it.uu.se/~jan/html2ps-1.0b5.tar.gz $ tar -xzf html2ps-1.0b5.tar.gz $ cd html2ps-1.0b5 $ sudo ./install
Next, download and install Mindtouch:
$ cd ~/Downloads $ wget http://s3.amazonaws.com/mindtouch/MindTouch_Core_9.12.2_Source.tar.gz $ tar xfvz MindTouch_Core_9.12.2_Source.tar.gz $ cd MindTouch_Core_9.12.2_Source $ mkdir ~/Sites/wiki.localdomain $ cp -r web/* ~/Sites/wiki.localdomain/ $ chmod a+w ~/Sites/wiki.localdomain/config/
Now, add a virtualhost to httpd.conf or an included vhosts config:
<VirtualHost *:80> ServerName wiki.localdomain DocumentRoot "/Users/YOUR-USERNAME-HERE/Sites/wiki.localdomain" RewriteEngine On RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^/$ /index.php?title= [L,NE] RewriteCond %{REQUEST_URI} ^/@gui/[^.]+$ RewriteRule ^/@gui/(.*)$ /proxy.php?path=$1 [L,QSA,NE] RewriteCond %{REQUEST_URI} !^/(@api|editor|skins|config|@gui)/ RewriteCond %{REQUEST_URI} !^/index\.php RewriteCond %{REQUEST_URI} !^/favicon\.ico$ RewriteCond %{REQUEST_URI} !^/robots\.txt$ RewriteCond %{QUERY_STRING} ^$ [OR] %{REQUEST_URI} ^/Special:Search RewriteRule ^/(.*)$ /index.php?title=$1 [L,QSA,NE] # deki-api uses encoded slashes in query parameters so AllowEncodedSlashes must be On AllowEncodedSlashes On <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> # mod_proxy rules ProxyPass /@api http://localhost:8081 retry=1 ProxyPassReverse /@api http://localhost:8081 SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 ## Logging ## # Possible values: debug, info, notice, warn, error, crit, alert, emerg LogLevel error CustomLog "/var/log/apache2/wiki.access.log" combined ErrorLog "/var/log/apache2/wiki.error.log" </VirtualHost>
I encountered an error at this point when I tried to visit the website. I assume this is a string parsing bug.
Error: MySQL enabled, but client version is too old: mysqlnd 5.0.7-dev - 091210 - $Revision: 294543 $. We require at least version 5.0.0 of the PHP MySQL client.
The “fix” was a bit more heavy handed than I normally prefer, but it works.
Open up the file ~/Sites/wiki.localdomain/maintenance/install-utils.inc and comment out the MySQL check.
Mine was at lines 43-48.
/*
$client_ver = mysql_get_client_info();
if ( !version_compare($client_ver, REQUIRED_MYSQL_VERSION, ">="))
{
echo_fail(wfMsg('Page.Install.check-mysqlc-fail', htmlspecialchars($client_ver), REQUIRED_MYSQL_VERSION));
$return = false;
}
*/After fixing the errors, visit http://wiki.localdomain and perform your initial setup.
Once setup is complete, you’ll need to locate your api key for use in next step:
$ cat /Users/YOUR-USERNAME/Sites/wiki.localdomain/LocalSettings.php |grep wgDekiApiKey|awk -F\" '{print $2}'
Next, edit /Library/LaunchDaemons/com.mindtouch.dekiwiki.plist and use this template:
(You’ll need to input your api key, and username into the template)
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>KeepAlive</key> <true/> <key>Label</key> <string>com.mindtouch.dekiwiki.itasca</string> <key>ProgramArguments</key> <array> <string>sudo</string> <string>/usr/bin/mono</string> <string>/User/YOUR-USERNAME/Sites/wiki.localdomain/bin/mindtouch.host.exe</string> <string>apikey</string> <string>ENTER-API-KEY</string> <string>script</string> <string>/etc/dekiwiki/mindtouch.deki.startup.xml</string> <string>path-prefix</string> <string>@api</string> <string>http-port</string> <string>8081</string> <string>ip</string> <string>localhost</string> <string>notty</string> <string>connect-limit</string> <string>-5</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
Start the dekihost service on computer start.
$ sudo launchctl load /Library/LaunchDaemons/com.mindtouch.dekiwiki.plist
That’s it!
You should be up and running now.
Site content and design copyright 2005-2010 bsd.bz