<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nathan Bridgewater &#187; Mono</title>
	<atom:link href="http://www.integratedwebsystems.com/category/dotnet/mono/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.integratedwebsystems.com</link>
	<description>My Little .NET Sandbox</description>
	<lastBuildDate>Fri, 10 Sep 2010 16:13:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Install Mono Daily Build Script for Fedora 13</title>
		<link>http://www.integratedwebsystems.com/2010/09/install-mono-daily-build-script-for-fedora-13/</link>
		<comments>http://www.integratedwebsystems.com/2010/09/install-mono-daily-build-script-for-fedora-13/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 15:01:03 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Fedora]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[Install]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[trunk]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=955</guid>
		<description><![CDATA[A while back I added a Fedora 13 install script for Mono that downloads, builds, and installs the last tested daily build along with xsp and mod_mono. I just recently updated it to use the Sept 1st, 2010 daily build. You can pull the latest script directly from my website or from my repository on [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Mono Project" href="http://www.mono-project.com/"><img style="border-bottom: 0px solid; border-left: 0px solid; width: 100px; float: right; height: 120px; border-top: 0px solid; border-right: 0px solid" alt="Mono Project" src="/wp-content/uploads/2010/08/Monogorillaaqua.100px.png" /></a><a href="http://fedoraproject.org"><img style="border-right-width: 0px; width: 207px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; height: 169px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Fedora Project" alt="Fedora 13" src="/wp-content/uploads/2010/09/fedora.png" /></a> A while back I added a Fedora 13 install script for Mono that downloads, builds, and installs the last tested daily build along with xsp and mod_mono.</p>
<p>I just recently updated it to use the Sept 1st, 2010 <a href="http://mono.ximian.com/daily/">daily build</a>. You can pull the latest script directly from my <a href="http://www.integratedwebsystems.com/resources/p796/fedora_mono-trunk.sh">website</a> or from my <a href="http://github.com/nathanb/iws-snippets">repository</a> on <a href="http://www.github.com">github</a>.</p>
<p>&#160;</p>
<h2>Script Usage</h2>
<p>My test environment was a standard web server install from the Fedora 13 download DVD.&#160; After the install, I started the same process I performed with the Ubuntu install, which was something like this:</p>
<pre class="brush: bash; gutter: false;">mkdir mono
cd mono
wget http://www.integratedwebsystems.com/resources/p796/fedora_mono-trunk.sh
chmod 744 fed*.sh
./fedora_mono-trunk.sh</pre>
<p>That’s it. It’ll first install all the required dependencies for the build and the web server. It’ll then download the 9/1 build (or latest tested version) from the daily tarball list and pull mod_mono and xsp from subversion trunk. Finally, it will extract, compile, and install everything. </p>
<p>The only thing remaining is to setup a web application and configure apache to use mod_mono. For this, I like to use the <a href="http://www.go-mono.com/config-mod-mono/">Mod Mono Config Tool</a> as a starting point to build my virtual host configuration file. </p>
<p>Setup your web server: </p>
<ol>
<li>Move the mod_mono.conf from /etc/httpd/conf to /etc/httpd/conf.d</li>
<li>Create a new directory to hold your virtual host config files at: /etc/httpd/sites-enabled<br />
    <br />mkdir /etc/httpd/sites-enabled</li>
<li>Copy your new virtual host config file to /etc/httpd/sites-enabled</li>
<li>Append a virtual host config line to your httpd.conf<br />
    <br />echo ”Include sites-enabled/*.*” &gt;&gt; /etc/httpd/conf/httpd.conf</li>
<li>Disable Selinux by editing the /etc/selinux/config file and changing SELINUX=disabled</li>
<li>Reboot server</li>
<li>Start web server if it isn’t configured to auto-start. (use chkconfig to set auto-start)<br />
    <br />service httpd start</li>
</ol>
<p>That should do it. You can test your new virtual host by browsing to it. The 404 response should show the new mod-mono version. </p>
<p>Good luck! </p>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/09/install-mono-daily-build-script-for-fedora-13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SubSonic3 Works on Mono!</title>
		<link>http://www.integratedwebsystems.com/2010/08/subsonic3-works-on-mono/</link>
		<comments>http://www.integratedwebsystems.com/2010/08/subsonic3-works-on-mono/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 05:00:00 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[ADO.Net]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[POCO]]></category>
		<category><![CDATA[SubSonic]]></category>
		<category><![CDATA[T4]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=773</guid>
		<description><![CDATA[So a couple weeks ago I decided to test a few changes made to SubSonic3 that fixed a LINQ evaluation bug related to medium trust. Using a simple console app on linux/mono, I tested basic data access to a SQLite database using repository mode, and to my surprise it worked! I&#8217;ve always been a big [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.subsonicproject.com"><img style="border-right-width: 0px; width: 280px; margin-bottom: 1em; float: right; border-top-width: 0px; border-bottom-width: 0px; height: 41px; margin-left: 1em; border-left-width: 0px" alt="SubSonic  Project" src="http://www.subsonicproject.com/content/images/SubSonicSMall.png" /></a>So a couple weeks ago I decided to test a few changes made to <a href="http://www.subsonicproject.com">SubSonic3</a> that fixed a LINQ evaluation bug related to medium trust. Using a simple console app on linux/mono, I tested basic data access to a SQLite database using repository mode, and to my surprise it worked! </p>
<p><a href="http://www.mono-project.com"><img style="border-right-width: 0px; margin: 0px 10px 10px 0px; width: 100px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; height: 120px; border-left-width: 0px" title="Mono-gorilla-aqua.100px" border="0" alt="Mono-gorilla-aqua.100px" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/08/Monogorillaaqua.100px1.png" width="100" height="120" /></a></p>
<p>I&#8217;ve always been a big fan of SubSonic since its 2.0 version, which I used for a mid-sized e-commerce site. With a totally rewritten core, 3.0 uses LINQ (language integrated query) for all of its data access providing a great alternative to Dblinq for the Mono platform.</p>
<p>&#160;</p>
<p>&#160;</p>
</p>
<p> <span id="more-773"></span>
</p>
<p>SubSonic3 supports <a href="http://www.subsonicproject.com/docs/Using_ActiveRecord">ActiveRecord</a>, <a href="http://subsonicproject.com/docs/Using_SimpleRepository">Repository</a>, and <a href="http://www.subsonicproject.com/docs/Using_AdvancedTemplates">Custom Linq</a> modes, which give you the flexibility to build code-first or database-first.&#160; SubSonic3 is not an ORM (object relational mapping) like <a href="http://www.nhibernate.com/">NHibernate</a>, but it can behave like one when you use Repository Mode using POCO (plain old CLR object) representations of your tables. SubSonic handles the mapping and database query generation itself based on the database provider configured. Its intention is to allow you to build code-first and let the persistence of the object be non-critical to your application. It can even migrate your class definition changes (table schema) to the database automatically during runtime; however, it still has the flexibility to let you design your database with keys, indexes, and constraints yourself without using the automatic migration. The <a href="http://www.subsonicproject.com">SubSonic website</a> has a <a href="http://subsonicproject.com/docs/Simple_Repo_5_Minute_Demo">great demo</a> showing this capability.</p>
<h3>Database Independence</h3>
<p>To make SubSonc3 truly database agnostic, you have to use Repository mode. Active Record and Custom Linq modes DO support multiple database engines, but they all require custom class generation which is hard-wired to those engines. So when you change database types like from MySql to MSSQL or vice-versa, you have to regenerate your classes.</p>
<p>With Repository mode, you simply change your connection string in the app.config. It will use the 2.0 Data Provider model provided by the database engine client and the definition of your POCO classes to determine the SQL syntax and schema to use.&#160; SubSonic is pre-wired with MSSql, SQLite, MySql, and a generic ANSI Sql syntax support. There&#8217;s been lots of talk about implementing Oracle and PostgreSql, which may already work in ActiveRecord or LinqTemplates, but are not yet in the Core assembly for use with Repository.</p>
<h3>Decoupled &#8211; Mocking for Unit Tests and Framework Independence</h3>
<p>Another big advantage of Repository is the ability to decouple your data framework from your application completely. Since the POCO objects are not directly tied to SubSonic, they can be re-used with other frameworks like <a href="http://www.nhibernate.com">NHibernate</a> or the latest <a href="http://blogs.msdn.com/b/adonet/archive/2010/07/14/ctp4codefirstwalkthrough.aspx">Entity Framework 4</a> without touching a single line of application code. It also opens the door to mocking and testability. Dependency Injection frameworks like <a href="http://unity.codeplex.com/">Unity</a> or <a href="http://structuremap.github.com/structuremap/index.html">StructureMap</a> work perfect for this.</p>
<h3>So how about a sample?</h3>
<p>This is a silly little test application that is neither pretty nor elegant, but it proves that this code will run on Mono 2.6.3 and 2.7 (trunk) with a SQLite database. It also uses Unity for dependency injection much like you would in Asp.NET MVC. Within the project, you&#8217;ll find an AppService interface used to provide the definition for simple &#8216;business&#8217; functionality. This is meant to be generic for the sample; but in a real application, I would breakdown the services by functional purpose. They all can share the same LinqRepository data interface, which provides basic rules for LINQ-based CRUD. SubSonic3 hooks right into that and is nearly transparent to the application with the exception of a few attributes on the domain objects. There are some placeholder Mock classes there and sample mappings in the code just for show.</p>
<p><a href="/resources/p773/SubSonicDemo.zip">Download the sample project</a></p>
<p>You can also get the latest version from <a href="http://github.com/nathanb/iws-snippets">IWS Snippets project</a> subversion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/08/subsonic3-works-on-mono/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MVC2 on Mono &#8211; Tips and Tricks for Windows Developers</title>
		<link>http://www.integratedwebsystems.com/2010/07/mvc2-on-mono-tips-and-tricks/</link>
		<comments>http://www.integratedwebsystems.com/2010/07/mvc2-on-mono-tips-and-tricks/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 17:00:00 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[MVC2]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=886</guid>
		<description><![CDATA[So lately, I&#8217;ve been pretty wrapped up with kids and family so I haven&#8217;t had much time to post anything new.&#160; However, I did start a new project, which I&#8217;ll detail out more as I go. It&#8217;s been quite the experience so far since I decided to build this one from the ground up using [...]]]></description>
			<content:encoded><![CDATA[<p>So lately, I&rsquo;ve been pretty wrapped up with kids and family so I haven&rsquo;t had much time to post anything new.&nbsp; However, I did start a new project, which I&rsquo;ll detail out more as I go. It&rsquo;s been quite the experience so far since I decided to build this one from the ground up using MySql and Linux/Mono.&nbsp; I&rsquo;ve never designed apps like that before. For one, I&rsquo;ve had to learn a new set of design tools for MySql as opposed to my comfortable Sql Management Studio. And I&rsquo;ve also had to very incrementally test different programming technologies and methods that were questionably supported in Linux/Mono.&nbsp; The beauty of this is that no matter what I do to make it work for Mono, the app will always work on Windows, and there&rsquo;s little development time lost if I have to fall back to its native platform.</p>
<p><span id="more-886"></span></p>
<p>So about this project&hellip;&nbsp; Well it&rsquo;s a simple project really: web based, MVC2 with a MySql database. So here&rsquo;s a few technical issues I ran into while building the beginnings of this application.</p>
<h3>Choosing a Data Framework</h3>
<p>I know some of you purists would say stick to vanilla ADO.NET; it works every time, and you have no conversion problems. Well, that&rsquo;s right, but I&rsquo;m a lazy typist, and I really dig LINQ. So I tested several LINQ data frameworks on mono and found that <a href="http://code.google.com/p/dblinq2007/">Dblinq</a>&nbsp;and <a href="http://www.subsonicproject.com/">SubSonic3</a>&nbsp;were the most functionally supported frameworks. I tested it with Linq to NHibernate, but it&nbsp;didn&#39;t work. SubSonic3, after a recent bug fix, now does work in Mono!&nbsp;</p>
<h3>MVC2 Works on Mono?</h3>
<p>Yeah it does! Well mostly and only if you pull from the trunk code or the daily tarballs. Unfortunately, it does not work with the latest public release 2.6.4 and definitely not 2.4.4 which is the latest deployed version on Ubuntu 10.04. MVC1 does work out of the box on both of those. But I&rsquo;ve been spoiling myself on MVC2 while at my fulltime job, so I decided to push for MVC 2.0 for this. So what do you have to do to get it working?&nbsp; You need to learn a little bit about compiling Mono on your own and installing it, which sounds more painful that it really is. I even wrote a script that works (most of the time) on Ubuntu.&nbsp; There&rsquo;s no guarantee that it will work for you of course. <img src='http://www.integratedwebsystems.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Checkout one of my recent posts about getting <a href="http://www.integratedwebsystems.com/2010/06/installing-mono-tagged-version-or-trunk-from-subversion-source-on-ubuntu-9-10-10-04/">Mono trunk installed</a>.</p>
<p>Using MVC2 is the easy part. Just setup a new MVC2 project and ensure your reference options for the System.Web.Mvc and System.Web.Routing assemblies are set to Copy Local. Data annotations will not work, so you&rsquo;ll need to rip out the model validation in the default MVC2 project; otherwise, the rest of it works like a charm.</p>
<h3>xUnit and Dependency injection with Unity works too!</h3>
<p>Yup, believe it or not, some of the components in the Enterprise Library do work in Mono including <a href="http://unity.codeplex.com/">Unity</a>, which works great for swapping out mock classes in test projects. I chose to use <a href="http://xunit.codeplex.com/">xUnit</a> as my testing framework since it seemed to work pretty nicely in the <a href="http://www.subsonicproject.com">SubSonic project</a>. I also found a real nice <a href="http://xunit.codeplex.com/wikipage?title=Comparisons&amp;referringTitle=Home">breakdown</a> of how they compare to other testing frameworks. The xunit command line runs on vanilla Ubuntu 10.04 (mono 2.4.4). However, my preferred method of running some of these tests is using the <a href="http://www.testdriven.net/">TestDriven.net runner</a> on Windows/VS.</p>
<h3>System Agnostic Gotchas</h3>
<p>I&rsquo;ve built and tested most of it on Windows. Which sometimes creates problems when deploying to non-Windows servers. Especially when it comes to I/O pathing.&nbsp; As you go through and design it, you always have to build it in a platform agnostic manner. Duh right?&nbsp; This includes simple things like case senstive paths, using the correct directory separators, etc. Typically as lazy Windows programmers (not all of us) <img src='http://www.integratedwebsystems.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &nbsp; we would rather hard code the path separator like this.&nbsp;&nbsp; string.Format(@&ldquo;..\files\{0}&rdquo;, filename);&nbsp;&nbsp;&nbsp; But unfortunately that breaks Linux pathing. So by using Path.DirectorySeparator, it will automatically decide which is the correct character to use on either platform.<br />
	<em>string.Format(&ldquo;..{0}files{0}{1}&rdquo;, Path.DirectorySeparator, filename);</em></p>
<p>The later versions of windows also support both slashes, so you could get away with using forward slashes in windows I/O on Vista and 7.</p>
<p>It can be advantageous (if working with a web application) to use <em>System.Web.HttpContext.Current.Server.MapPath</em> or <em>System.Web.Hosting.HostingEnvironment.MapPath</em> to get your native local path from a virtual one. So store your paths as virtual ones and let the framework convert it to a native/local one.</p>
<h3>Image Rendering</h3>
<p>Well, I haven&rsquo;t completely dug into this, but I have briefly tested simple things like resizing images and writing them back out with Jpeg encoding. I have to say that the Mono built-in implementation of the GDI works just fine.&nbsp; I even tested some other things like rendering speed as far as resizing a jpeg and writing it out. It seems using the System.Drawing as opposed to Mono&rsquo;s GDK/Cairo actually works faster (only by observation; nothing official). I&rsquo;ll have more detailed results on this as I get to that piece.</p>
<h3>Wrap-Up</h3>
<p>So if you&rsquo;re interested in starting a new Mono project, I hope some of these tips will keep you out of trouble. Good Luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/07/mvc2-on-mono-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Installing Mono Trunk or 2.6.4 Tag with Subversion Source on Ubuntu 10.04 Lucid</title>
		<link>http://www.integratedwebsystems.com/2010/06/installing-mono-tagged-version-or-trunk-from-subversion-source-on-ubuntu-9-10-10-04/</link>
		<comments>http://www.integratedwebsystems.com/2010/06/installing-mono-tagged-version-or-trunk-from-subversion-source-on-ubuntu-9-10-10-04/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 14:42:00 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Mono]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Install]]></category>
		<category><![CDATA[lucid]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=796</guid>
		<description><![CDATA[Updated June 23, 2010! Lately, I’ve been really digging the new Ubuntu 10.04 on my desktop and web server. So I’ve been meaning to get a post out here describing how I got Mono trunk installed since it comes packaged with 2.4.4.&#160; After much testing, I finally have finished getting a script to work with [...]]]></description>
			<content:encoded><![CDATA[<h4>Updated June 23, 2010!</h4>
<p>Lately, I’ve been really digging the new Ubuntu 10.04 on my desktop and web server. So I’ve been meaning to get a post out here describing how I got Mono trunk installed since it comes packaged with 2.4.4.&#160; After much testing, I finally have finished getting a script to work with a fresh, vanilla install. </p>
<p>I stumbled on this <a href="http://www.bscheiman.org/2010/01/31/compiling-mono-svn-on-slicehost/">blog post by Boris Schieman</a> where he wrote a bash script to compile and install the Mono trunk.&#160; I made a few tweaks to it for a vanilla linux install for the tagged 2.6.4 release and setup another one for updating a mono trunk build using the daily tarballs. I’ve successfully tested both versions on Ubuntu 10.04 Lucid. I’m just a casual linux/mono user, so use this at your own risk.</p>
</p>
<p> <span id="more-796"></span>
</p>
<h3>Steps to Install</h3>
<p>Starting with a fresh install of Ubuntu 10.04 Server, these steps can be run from the console or via SSH. Lately, I’ve been testing the trunk script more thoroughly than the tagged version, but they both should work.&#160; As always, checkout <a href="http://www.mono-project.com">http://www.mono-project.com</a> to get more detailed information about the different versions available and this install process. For the tagged 2.6.4 install, I chose to use the packaged mono to support compiling this one; so when it’s done, you’ll end up with two versions of mono installed. The packaged version is 2.4.4 located at: /usr/bin&#160; and this compiled version will be located at /usr/local/bin and should be the default after it’s installed. These steps are basically the same for both versions. Just switch out the url for the script if you want to install the 2.6.4 tag.</p>
<p><strong>Step by Step</strong></p>
<ol>
<li>Create a new directory in your home directory called mono.      <br /><em>mkdir mono        <br />cd mono</em> </li>
<li>Copy the script to this folder and make it executable      <br /><em>wget </em><em><a href="http://www.integratedwebsystems.com/resources/p796/install_mono-trunk.sh">http://www.integratedwebsystems.com/resources/p796/install_mono-trunk.sh</a></em>       <br /><em>chmod 744 install_mono-trunk.sh</em> </li>
<li>Execute it. (without sudo; you will be prompted occasionally for your sudo password during install phases)      <br /><em>./install_mono-trunk.sh </em></li>
<li>Check the install – sometimes the trunk doesn’t always compile fully or install correctly.&#160; Check your /usr/local/bin folder to see what was installed.&#160; You can also run <em>mono –V</em> to see the current runtime version, which should be the date of the tarball 20100618, etc.&#160; (equivalent of 2.7 trunk)&#160; <br /><em>ls /usr/local/bin</em> </li>
<li>Setup Mod_Mono by moving the config file and enabling it for apache      <br /><em>sudo mv /etc/apache2/mod_mono.conf /etc/apache2/mods-available</em>&#160; <br /><em>sudo ln -s /etc/apache2/mods-available/mod_mono.conf /etc/apache2/mods-enabled/mono.conf</font>&#160; </em></li>
<li>Check your apache site configurations to ensure they’re using the correct path to mod-mono-server2 located at /usr/local/bin. I use the <a href="http://go-mono.com/config-mod-mono/">mod_mono configuration tool</a> and then change the path it generates. Restart Apache when you’re done.       <br /><em>sudo service apache2 restart</em> </li>
</ol>
<p>&#160;</p>
<p><a class="lightbox" title="List of /usr/local/bin" href="/resources/p796/1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="List of /usr/local/bin after install" border="0" alt="List of /usr/local/bin after install" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/06/image.png" width="404" height="272" /></a> </p>
<p>&#160;</p>
<h3>Download Scripts</h3>
<p><a href="/resources/p796/install_mono-2-6-4.sh">Install Mono SVN Tag 2.6.4</a></p>
<p><a href="/resources/p796/install_mono-trunk.sh">Install Mono Trunk</a> (updated 2/26/2010)</p>
<p><a href="/resources/p796/update_mono.sh">Update Mono Install</a> (updated 2/26/2010)</p>
<p>&#160;</p>
<p><strong>Install Script for Trunk</strong></p>
<pre class="brush: bash; gutter: false;">#!/bin/bash

TOPDIR=$(pwd)
BUILDDIR=$TOPDIR/build
DLDDIR=$TOPDIR/downloads

export PATH=/usr/local/bin:$PATH

echo &quot;updating existing system&quot;
sudo apt-get update
sudo apt-get upgrade -y

echo &quot;installing prerequisites&quot;
sudo apt-get install -y build-essential libc6-dev g++ gcc libglib2.0-dev pkg-config subversion apache2 apache2-threaded-dev bison gettext autoconf automake libtool

mkdir -p $BUILDDIR

echo
echo &quot;downloading mono packages&quot;
echo

cd $BUILDDIR

svn co svn://anonsvn.mono-project.com/source/trunk/xsp
svn co svn://anonsvn.mono-project.com/source/trunk/mod_mono

wget http://mono.ximian.com/daily/mono-latest.tar.bz2
wget http://mono.ximian.com/daily/monocharge-latest.tar.gz

cd $BUILDDIR
bunzip2 -df mono-latest.tar.bz2
tar -xvf mono-latest.tar
tar -xzvf monocharge-latest.tar.gz

echo
echo &quot;building and installing mono packages&quot;
echo
cd $BUILDDIR
cd mono-*
./configure --prefix=/usr/local --with-glib=system
make
sudo make install

cd $BUILDDIR
cd monocharge*
sudo env prefix=/usr/local ./recharge.sh

cd $BUILDDIR
cd xsp
./autogen.sh --prefix=/usr/local
make
sudo make install

cd $BUILDDIR
cd mod_mono
./autogen.sh --prefix=/usr/local
make
sudo make install
cd $BUILDDIR

echo
echo &quot;done&quot;</pre>
<p>Good luck! </p>
<p><link rel="stylesheet" type="text/css" href="/css/jquery.lightbox-0.5.css" />
<script type="text/javascript" src="http://www.google.com/jsapi"></script><br />
<script type="text/javascript">
	google.load("jquery", "1.4.1");
	</script><br />
<script type="text/javascript" src="/js/jquery.lightbox-0.5.pack.js"></script><br />
<script type="text/javascript" src="/tools/js/lightbox.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/06/installing-mono-tagged-version-or-trunk-from-subversion-source-on-ubuntu-9-10-10-04/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Walkthrough: Porting Asp.Net MVC Website to Mono 2.6.1 and MySql on Linux Apache &#8211; Porting to Mono Part 3 of 3</title>
		<link>http://www.integratedwebsystems.com/2010/02/walkthrough-porting-asp-net-mvc-website-to-mono-2-6-1-and-mysql-on-linux-apache-porting-to-mono-part-3-of-3/</link>
		<comments>http://www.integratedwebsystems.com/2010/02/walkthrough-porting-asp-net-mvc-website-to-mono-2-6-1-and-mysql-on-linux-apache-porting-to-mono-part-3-of-3/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 04:21:00 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Mono]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=447</guid>
		<description><![CDATA[So for the third and final part of this series, I want to walk through how I ported a very small project I posted on CodePlex awhile back called SiteManager. It is an extremely simplified CMS application that I wrote using Linq to Sql and MVC in order to provide a very basic and easy [...]]]></description>
			<content:encoded><![CDATA[<p sizcache="0" sizset="0">So for the third and final part of this series, I want to walk through how I ported a very small project I posted on CodePlex awhile back called <a href="http://sitemanager.codeplex.com" target="_blank">SiteManager</a>. It is an extremely simplified CMS application that I wrote using Linq to Sql and MVC in order to provide a very basic and easy website tool. It uses membership provider for authentication and Linq to Sql Classes with its database in MS Sql Server. For this walkthrough, I’ll be converting the database to MySql and adapting Linq to Sql to Dblinq so it can completely run on Mono and Linux.</p>
</p>
<p> <span id="more-447"></span>
<link rel="stylesheet" type="text/css" href="/css/jquery.lightbox-0.5.css" />
<h3>Index</h3>
<ul sizcache="0" sizset="1">
<li sizcache="0" sizset="1"><a href="#start">Getting Started</a> </li>
<li sizcache="0" sizset="2"><a href="#database">Database Migration</a> </li>
<li sizcache="0" sizset="3"><a href="#l2s">Linq to Sql to Dblinq</a> </li>
<li sizcache="0" sizset="4"><a href="#membership">Membership</a> </li>
<li sizcache="0" sizset="5"><a href="#authorization">Authorization</a> </li>
<li sizcache="0" sizset="6"><a href="#deployment">Deployment</a> </li>
<li sizcache="0" sizset="7"><a href="#vim">VIM (Editing code files on the server)</a> </li>
<li sizcache="0" sizset="8"><a href="#wrapup">Wrap Up</a> </li>
<li sizcache="0" sizset="9"><a href="#source">Get the Source</a> </li>
</ul>
<h3 sizcache="0" sizset="10"><a name="start">Getting Started</a></h3>
<p sizcache="0" sizset="11">Since I’ve already ported this application, it is very easy to identify any of the problem points. But for any new project, I would identify the basic items related to common issues with changing platforms like: data access, authentication, and any operating system specific code. Using the <a href="http://mono-project.com/MoMA" target="_blank">MoMA tool</a> is hugely beneficial to see how your code base might fare in the Mono framework. It will point out any specific code you’re using that could cause problems.&#160;&#160; You should also <a href="http://mono-project.com/Start" target="_blank">browse the Mono site</a> and learn some basics about the framework since they have quite a few useful extended frameworks that are not part of the Windows .Net runtime.&#160; They also have another nice guide out there for <a href="http://www.mono-project.com/Guide:_Porting_ASP.NET_Applications">porting Asp.Net applications</a> where they use PostgreSql and Blog Starter Kit.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="14"><a name="database">Database Migration</a></h3>
<p>You should know that Microsoft Sql Server works fine with Mono and works well when you are in a Windows environment and want to run Mono applications against existing Sql Servers. Since we’re running this application completely on a Linux server, as you might do in a hosted Linux environment, leaving our database in Sql Server isn’t an option.&#160; I chose to migrate to MySql purely for personal preference since I have a little more experience with this one rather than others like PostgreSql or Sqlite. However with Dblinq, you will have quite a few options.</p>
<h4>Create an Empty MySql Database and an Application User</h4>
<p sizcache="0" sizset="15">If you recall from my first post in this series, we <a href="http://www.integratedwebsystems.com/2010/01/installing-opensuse-11-2-with-mono-2-6-1-and-apache-using-text-mode-configuration-porting-to-mono-part-1-of-3/#InstallMonoAndApache">installed and configured MySql server</a>.&#160;&#160; We also discussed creating new users. You will want to create a new database with a new user who has access to it from the local machine. (Note that this can also be performed with the <a href="http://dev.mysql.com/downloads/workbench/5.2.html" target="_blank">MySql Workbench GUI Tools</a>).</p>
<p>So to begin, using Putty, SSH into your server.&#160; Then run:</p>
<pre class="brush: sql; gutter: false;">root@server: mysql -u admin_username -p
Enter password: ********
create database sitemanager_mono;
grant all privileges on sitemanager_mono.* to 'aspnet'@'localhost' identified by 'pass';
quit</pre>
<p>You may want to replace the username and password I used here with something more secure, but for this demo I kept it simple. You can do that by replacing ‘aspnet’ with a username of your choice and ‘pass’ with a password of your choice.</p>
<p>You now have a new empty database with its own power user account that can only access it from the local machine. This will be our application user so keep the credentials handy for later when we edit the config file.</p>
<h4>Migrating Sql Server Schema to MySql</h4>
<p sizcache="0" sizset="17">I used the <a href="http://dev.mysql.com/downloads/workbench/5.2.html" target="_blank">MySql Migration Toolkit</a> (part of the GUI Workbench) to perform my migration. It actually worked out pretty well with the exception of a few data type conversions. I like to use varchar(max) fields in Sql server. I also use bit fields for booleans since they parse right over to C# booleans.&#160; The migration tool didnt’ like varchar(max) and converted them to varchar(-1). It also converted my bit fields to tinyint(4). So during the migration, I was able to make edits to a few of my tables that contained those fields. For varchar(max), you have a choice. You can: use a smaller field like varchar(5000), use a Text field, or you can choose to store your text data in a binary blob and encode/decode it to UTF8.&#160; For this, application, I went the route of selecting a smaller varchar field for simplicity; but if my content pages were large, I would probably go the route of text. I found some <a href="http://www.pythian.com/news/7129/text-vs-varchar/" target="_blank">interesting discussion in this post on the topic.</a></p>
<p>So in order, here are the steps I took using the migration tool:</p>
<table border="0" cellspacing="0" cellpadding="2" width="561" sizcache="0" sizset="19">
<tbody sizcache="0" sizset="19">
<tr sizcache="0" sizset="19">
<td valign="top" width="263" sizcache="0" sizset="19"><a class="lightbox" title="Step 1" href="/resources/p447/1.jpg" jquery1267071925472="12" jquery1267072108070="12"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 1" border="0" alt="Step 1" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/1.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">&#160;</td>
</tr>
<tr sizcache="0" sizset="20">
<td valign="top" width="263" sizcache="0" sizset="20"><a class="lightbox" title="Step 2" href="/resources/p447/2.jpg" jquery1267071925472="14" jquery1267072108070="14"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 2" border="0" alt="Step 2" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/2.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">
<p>Choose your source database.</p>
</td>
</tr>
<tr sizcache="0" sizset="21">
<td valign="top" width="263" sizcache="0" sizset="21"><a class="lightbox" title="Step 3" href="/resources/p447/3.jpg" jquery1267071925472="16" jquery1267072108070="16"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 3" border="0" alt="Step 3" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/3.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">
<p>Choose your target database.</p>
</td>
</tr>
<tr sizcache="0" sizset="22">
<td valign="top" width="263" sizcache="0" sizset="22"><a class="lightbox" title="Step 4" href="/resources/p447/4.jpg" jquery1267071925472="18" jquery1267072108070="18"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 4" border="0" alt="Step 4" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/4.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Select the source schema. </td>
</tr>
<tr sizcache="0" sizset="23">
<td valign="top" width="263" sizcache="0" sizset="23"><a class="lightbox" title="Step 5" href="/resources/p447/5.jpg" jquery1267071925472="20" jquery1267072108070="20"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/5.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Add exclusions. I chose to exclude my membership tables since I configured those to use a different catalog. </td>
</tr>
<tr sizcache="0" sizset="24">
<td valign="top" width="263" sizcache="0" sizset="24"><a class="lightbox" title="Step 6" href="/resources/p447/6.jpg" jquery1267071925472="22" jquery1267072108070="22"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 6" border="0" alt="Step 6" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/6.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Utf-8 was fine for my solution</td>
</tr>
<tr sizcache="0" sizset="25">
<td valign="top" width="263" sizcache="0" sizset="25"><a class="lightbox" title="Step 7" href="/resources/p447/7.jpg" jquery1267071925472="24" jquery1267072108070="24"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 7" border="0" alt="Step 7" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/7.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Mapping error review</td>
</tr>
<tr sizcache="0" sizset="26">
<td valign="top" width="263" sizcache="0" sizset="26"><a class="lightbox" title="Step 8" href="/resources/p447/8.jpg" jquery1267071925472="26" jquery1267072108070="26"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 8" border="0" alt="Step 8" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/8.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Execution step</td>
</tr>
<tr sizcache="0" sizset="27">
<td valign="top" width="263" sizcache="0" sizset="27"><a class="lightbox" title="Step 9" href="/resources/p447/9.jpg" jquery1267071925472="28" jquery1267072108070="28"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 9" border="0" alt="Step 9" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/9.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">Execution results</td>
</tr>
<tr sizcache="0" sizset="28">
<td valign="top" width="263" sizcache="0" sizset="28"><a class="lightbox" title="Step 10" href="/resources/p447/10.jpg" jquery1267071925472="30" jquery1267072108070="30"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Step 10" border="0" alt="Step 10" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/02/10.jpg" width="244" height="178" /></a> </td>
<td valign="top" width="296">
<p>Script errors will appear on the last screen.&#160; Make the necessary changes, click Apply Changes, and Recreate Objects for each error.&#160; When finished, click next to finish.</p>
<p>This is where you’ll see varchar(-1) for conversion from varchar(max) fields.&#160; Change this to text or varchar(n).</p>
<p>Note that sql bit fields convert to smallint(4) if you wish to change that back to bit.</p>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<h3 sizcache="0" sizset="29"><a name="l2s">Linq to Sql Classes to Dblinq</a></h3>
<p>After fixing errors and executing the script, you should now have your full schema migrated to MySql. Now you need to convert your Linq to Sql to Dblinq. Mono uses Dblinq as its Linq to Sql replacement internally. I chose to manually use DBlinq because I wasn’t sure how much of the Dblinq code was available in Mono.&#160; I downloaded the current version of the Dblinq project from their public Subversion repository.</p>
<p>So the basic idea here is that we’re going to swap out L2S with Dblinq in a nearly transparent way.&#160; We’ll drop the existing DBML file from our project, use DBMetal.exe to regenerate new classes, and then update our DBFactory utility function to create a new data context from the DBlinq side.&#160;&#160; Essentially, this will allow us to re-use the same operational syntax in the Repository class with minimal changes.</p>
<p>For generating new classes, I used the DBMetal utility that comes with Dblinq. Here&#8217;s the batch file I setup to generate my code: </p>
<pre class="brush: bash; gutter: false;">REM: note that the '-sprocs' option is turned on

&quot;DbMetal.exe&quot; --provider=MySql -database:sitemanager_mono -server:carbuncle -user:user -password:pass &quot;-namespace:IWS.SiteManager.Core.Model&quot; -code:Generated.cs -sprocs --pluralize</pre>
<p>After generating the classes, I replaced the DBFactory GetProvider function with this: </p>
<pre class="brush: csharp; gutter: false;">public static Model.SiteManager GetProvider()
{
    var con_string = GetDefaultConnectionString();
    return new Model.SiteManager(new MySql.Data.MySqlClient.MySqlConnection(con_string));
}</pre>
<p>I used a repository class as a helper to access my data model. Each repository class contains its own instance of the data context (in this case, Data.SiteManager). During construction of the repository class, it creates a new instance of the data context so any of the factory functions are able to use it without maintaining their own context. So I replaced all the member variable types for existing data contexts with the new one generated from Dblinq. I also noticed Dblinq had different casing than the original column names.&#160; So where I had columns like, “ModifiedUTC” before, it was “ModifiedUtc” now. This was a pretty painless fix with find/replace.</p>
<p>You’ll notice here that the Linq syntax itself didn’t change at all.</p>
<pre class="brush: csharp; gutter: false;">public class ContentRepository
{
    SiteManager _DB;

    public ContentRepository()
    {
        _DB = DBFactory.GetProvider();
    }

    /// &lt;summary&gt;
    /// gets a page by its id
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;id&quot;&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public Content GetContent(int id)
    {
        return _DB.Contents.Where(o =&gt; o.ID == id).SingleOrDefault();
    }
    /// &lt;summary&gt;
    /// Load a page by its permalink.
    /// &lt;/summary&gt;
    /// &lt;param name=&quot;permalink&quot;&gt;&lt;/param&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public Content GetPage(string section, string permalink)
    {
        return _DB.Contents.Where(o =&gt; o.SectionID == section &amp;&amp; o.Permalink == permalink.Trim().ToLower()).SingleOrDefault();
    }
    /// &lt;summary&gt;
    /// gets the configured default page.
    /// &lt;/summary&gt;
    /// &lt;returns&gt;&lt;/returns&gt;
    public Content GetIndexPage(string section)
    {
        var data = _DB.Sections.Where(o =&gt; o.ID == section).SingleOrDefault();

        Content page = null;

        if (data != null &amp;&amp; data.DefaultContentID.HasValue)
            page = _DB.Contents.Where(o =&gt; o.ID == data.DefaultContentID.Value).SingleOrDefault;

        return page;
    }
    public string GetSectionIDForPage(int id)
    {
        var section = _DB.Contents.Where(o =&gt; o.ID == id).Select(o =&gt; o.SectionID).SingleOrDefault();
        return section;
    }
    public void SaveContent(Content content)
    {
        Section section = null;

        if (_DB.Sections.Where(o =&gt; o.ID == content.SectionID).Count() == 0)
        {
            section = new Section();
            section.ID = content.SectionID;
            section.Description = &quot;Auto-generated section for new page.&quot;;
            _DB.Sections.InsertOnSubmit(section);
            _DB.SubmitChanges();
        }

        //take current version, push it to content history, overwrite current with new.
        Content old = this.GetContent(content.ID);
        if (old != null)
        {
            //archive old version.
            ContentHistory row = new ContentHistory();
            row.ContentID = content.ID;
            row.Body = old.Body;
            row.CreatedUtc = DateTime.UtcNow;
            _DB.ContentHistories.InsertOnSubmit(row);
            _DB.SubmitChanges();

            old.LoadFromExisting(content); //load current values
        }
        else
        {
            old = content;
            _DB.Contents.InsertOnSubmit(old);
        }

        _DB.SubmitChanges();

        if (section != null) //was a new one. set the default content id.
        {
            section.DefaultContentID = content.ID;
            _DB.SubmitChanges();
        }
    }
    public void DeleteContent(int id)
    {
        var data = _DB.Contents.Where(o =&gt; o.ID == id).SingleOrDefault();
        if (data != null)
        {
            //remove conflicts first.
            var section = this.GetSectionByID(data.SectionID);
            if (section != null)
            {
                section.DefaultContentID = null;
                _DB.SubmitChanges();
            }

            _DB.Contents.DeleteOnSubmit(data);
            _DB.SubmitChanges();
        }
    }
}</pre>
<p>At this point, the project should be compilable. You may need to make a few tweaks to get the loose ends tied up.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="30"><a name="membership">Membership Provider</a></h3>
<p sizcache="0" sizset="31">After following the <a href="http://www.integratedwebsystems.com/2010/02/how-to-setup-and-configure-mysql-membership-provider-6-2-2-porting-to-mono-part-2-of-3/" target="_blank">instructions from the last post</a>, you should get your membership provider setup and configured. For Mono, I think the biggest hang up for me was not being able to use hashed passwords. Alternatively, you can investigate using encrypted passwords. For simplicity, I used clear text passwords here.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="32"><a name="authorization">Membership Authorization</a></h3>
<p>You should now have a runable MVC application. Almost everything should work with exception to how security applies rules from the web.config.&#160; I noticed Mono doesn’t apply the same security authorization rules to paths for MVC like it does for web forms. I removed &lt;location path=””&gt; tags from my config file and placed the authorization restrictions to my controller actions instead. </p>
<p>So for example this config section would be used to restrict access to all actions in the Manage controller on Windows.</p>
<pre class="brush: xml; gutter: false;">&lt;location path=&quot;Manage&quot;&gt;
    &lt;system.web&gt;
        &lt;authorization&gt;
            &lt;allow roles=&quot;Admins,Editors&quot;/&gt;
            &lt;deny users=&quot;*&quot;/&gt;
        &lt;/authorization&gt;
    &lt;/system.web&gt;
&lt;/location&gt;</pre>
<p>So on Mono, we remove it from web.config and move to the manage controller as an attribute on ALL actions you want to restrict. This can become a maintenance hassle, but they may eventually fix this for MVC in Mono.</p>
<pre class="brush: csharp; gutter: false;">[Authorize(Roles=&quot;Admins,Editors&quot;)]
public ActionResult Index()
{
    return View();
}</pre>
<h3>&#160;</h3>
<h3 sizcache="0" sizset="33"><a name="deployment">Deployment</a></h3>
<p>Don’t forget to make changes to your web.config file. Include the credentials you setup for your database earlier.&#160; Then using Build-&gt;Publish, publish the site to a local folder. Don’t include the App_Data folder and have it delete all files before publishing. Then using FileZilla over SFTP, connect to your server and upload the published website to the web folder you configured. With the latest Mono, the website should automatically reload the new assemblies. If you have any doubt about this, you can always SSH into the server and restart apache.</p>
<p>To restart apache, gain root access using <strong>su</strong> and then: </p>
<pre class="brush: bash; gutter: false;">service apache2 restart</pre>
<p>Optionally, if restarting apache doesn’t seem to work, you can also search and kill off the mono processes:</p>
<pre class="brush: bash; gutter: false;">diabolos:/home/nathan # ps -A | grep mono
 2162 ?        00:00:03 mono
 2164 ?        00:00:08 mono
diabolos:/home/nathan # kill 2162
diabolos:/home/nathan # kill 2164</pre>
<p>The next request to the server will restart these processes as needed. </p>
<p>&#160;</p>
<h3 sizcache="0" sizset="34"><a name="vim">Quick Guide to VIM</a></h3>
<p>Every once in awhile, you may need to edit files that live on the server without going through the whole process of publishing, deploying, etc. To do this, I like to use a tool called VIM. So what is VIM?&#160; For those of you haven’t used it, it’s a simple text editor in Linux that comes with most distributions. You can think of VIM like “edit” for DOS on steroids. The OpenSuse version even has code completion and color-coded syntax, which is very neat.</p>
<p>To open a file with VIM, SSH into your server and run this command:</p>
<p>vi <em>filename</em></p>
<p>When you open the file, there isn’t a menu, but you’ll see ~ on the left and the text of your file.&#160; VIM has modes (much more than I’ll discuss here), but you need to know of at least two:&#160; insert mode and append mode.&#160; This will allow you to insert or append text starting at the cursor position. So move your cursor to any location and press <em><strong>i</strong></em> for insert mode. You will be able to freely type almost anything. To exit insert mode, hit <em><strong>Esc</strong></em>. Append mode uses the same behavior by pressing <em><strong>a</strong></em>. You will append text starting at the cursor position. Entering <strong><em>:d</em></strong> will delete the current line. Be sure not to use arrow keys while in an editing mode.</p>
<p>To save a file, press <strong><em>Esc </em></strong>to exit editing mode, and then press<strong><em> :w</em></strong> to write the file. You can then enter <strong><em>:q</em></strong> to quit.&#160;&#160; And to save and quit, use <strong><em>:wq.</em></strong>&#160; You can get more info by entering <strong><em>man vi</em></strong> at the command prompt.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="35"><a name="wrapup">Wrap Up</a></h3>
<p>So that’s it. This is a tiny project, but you may be able to apply these ideas to your own projects.&#160; For me, this gets my imagination fired up about what kinds of solutions I can take advantage of using Mono. I think there’s a lot of potential here.&#160; I’ve recently begun using interfaces and dependency injection with my projects for data frameworks to avoid the mess we covered in the Linq to Sql to Dblinq section. This means I can write a decoupled application that can optionally use Linq to Sql or Dblinq as a pluggable assembly that is injected using settings in my config file. This will make the transition between Windows and Mono much less painful.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="36"><a name="source">Get the Source</a></h3>
<p sizcache="0" sizset="37">To obtain the source, head over to <a href="http://sitemanager.codeplex.com/SourceControl/list/changesets" target="_blank">sitemanager.codeplex.com</a> and download the latest source.&#160; You’ll find the mono ported code under the /branches/mono-mysql-fork branch. </p>
<p>&#160;</p>
<h3>Useful Links</h3>
<ul sizcache="0" sizset="38">
<li sizcache="0" sizset="38"><a href="http://www.mono-project.com" target="_blank">Mono project</a> </li>
<li sizcache="0" sizset="39"><a href="http://mono-project.com/Start" target="_blank">Getting Started with Mono</a> </li>
<li sizcache="0" sizset="40"><a href="http://mono-project.com/Guide:_Porting_ASP.NET_Applications" target="_blank">Porting Asp.Net Applications</a> </li>
<li sizcache="0" sizset="41"><a href="http://dev.mysql.com/downloads/connector/net/" target="_blank">MySql .NET Connector</a> (I downloaded mono build &amp; source) </li>
<li sizcache="0" sizset="42"><a href="https://sitemanager.svn.codeplex.com/svn/branches/mono-mysql-fork" target="_blank">SiteManager CodePlex Mono Branch in Subversion</a> </li>
<li sizcache="0" sizset="43"><a href="http://linq.to/db" target="_blank">Dblinq website</a> </li>
<li sizcache="0" sizset="44"><a href="http://dblinq2007.googlecode.com/svn/trunk/" target="_blank">Dblinq Subversion</a> </li>
</ul>
<p><script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">
		google.load("jquery", "1.4.1");
	</script><script type="text/javascript" src="/js/jquery.lightbox-0.5.pack.js"></script><script type="text/javascript" src="/tools/js/lightbox.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/02/walkthrough-porting-asp-net-mvc-website-to-mono-2-6-1-and-mysql-on-linux-apache-porting-to-mono-part-3-of-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing OpenSuse 11.2 with Mono 2.6.1 and Apache Using Text Mode Configuration &#8211; Porting to Mono Part 1 of 3</title>
		<link>http://www.integratedwebsystems.com/2010/01/installing-opensuse-11-2-with-mono-2-6-1-and-apache-using-text-mode-configuration-porting-to-mono-part-1-of-3/</link>
		<comments>http://www.integratedwebsystems.com/2010/01/installing-opensuse-11-2-with-mono-2-6-1-and-apache-using-text-mode-configuration-porting-to-mono-part-1-of-3/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 13:30:00 +0000</pubDate>
		<dc:creator>Nathan</dc:creator>
				<category><![CDATA[Mono]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[installing]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mod_mono]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[openSuse]]></category>

		<guid isPermaLink="false">http://www.integratedwebsystems.com/?p=441</guid>
		<description><![CDATA[I’ve always kept an eye on the Mono project, mostly out of curiosity and intrigue. The last time I played around with Mono it was at version 2.0, and at the time I didn’t really spend a lot of time on it because it didn’t support some of the things I was using.&#160; Well recently, [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve always kept an eye on the Mono project, mostly out of curiosity and intrigue. The last time I played around with Mono it was at version 2.0, and at the time I didn’t really spend a lot of time on it because it didn’t support some of the things I was using.&#160; Well recently, I regained interest in Mono when I saw it now supports MVC and some of Dblinq. And since I’ve been buzzing on the whole MVC thing for awhile, I decided to check Mono out for myself and start a fun little porting project. So this is the first part of a three part series describing everything I did to get a server up and running and one of my Asp.Net MVC applications ported to Mono.</p>
<p>This first part will cover installing and configuring an OpenSuse 11.2 server with Apache/Mono and SSH. <a href="http://www.integratedwebsystems.com/2010/02/how-to-setup-and-configure-mysql-membership-provider-6-2-2-porting-to-mono-part-2-of-3/">The second part</a> will talk about how to setup a MySql Membership provider (with mono and Windows), and the third part is a walkthrough showing how to port a simple Asp.Net MVC site to mono and MySql. I’m also targeting those of you who use virtual hosting where you might only have SSH (after install) to configure your server, so I will be using text based tools: SSH, vi, and yast for all my installations and configuration after getting the base system installed.</p>
<p> <span id="more-441"></span>
<p><script type="text/javascript" src="http://www.google.com/jsapi"></script><script type="text/javascript">
		google.load("jquery", "1.4.1");
		google.load("jqueryui", "1.7.2");
	</script><script type="text/javascript" src="/js/jquery.lightbox-0.5.pack.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jquery.lightbox-0.5.css" media="screen" /><script type="text/javascript" src="/tools/js/p441.js"></script></p>
<p sizcache="0" sizset="0">First off, let me just say that I’m a Windows .NET programmer; not a Linux programmer. I know enough about Linux to dig my way around most of the basic stuff, so if anything seems incorrect in this post, feel free to correct me. <img src='http://www.integratedwebsystems.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> &#160; I’m extremely intrigued by Linux and its open source philosophy. I use it for a handful of useful, rock solid services like <a href="http://subversion.tigris.org/" target="_blank">Subversion</a>, <a href="http://www.postfix.org/" target="_blank">Postfix</a>, <a href="http://www.samba.org/" target="_blank">Samba</a> file servers and <a href="http://www.mysql.com/" target="_blank">MySql</a>. I also share an interest with many small web shops in finding more affordable hosting solutions for smaller Asp.Net apps. And in light of Mono being able to run MVC apps, it’s very exciting to think of what we can do with it.</p>
<h3>Index</h3>
<ul sizcache="0" sizset="4">
<li sizcache="0" sizset="4"><a href="#BeforeYouBegin">Before You Begin</a>&#160; </li>
<li sizcache="0" sizset="5"><a href="#InstallingLinuxPart1">Installing Linux Graphical (part 1)</a> </li>
<li sizcache="0" sizset="6"><a href="#InstallingLinuxPart2">Configuring Linux During Install (part 2)</a> </li>
<li sizcache="0" sizset="7"><a href="#ConfiguringLinuxAfterInstall">Configuring Linux After Install</a> </li>
<li sizcache="0" sizset="8"><a href="#UpdatingSoftware">Updating Software</a> </li>
<li sizcache="0" sizset="9"><a href="#InstallMonoAndApache">Install Mono, Apache, and MySql</a> </li>
<li sizcache="0" sizset="10"><a href="#ConfigureApache">Configure a Virtual Host &amp; Web Directory</a> </li>
<li sizcache="0" sizset="11"><a href="#RunningMVC">Running the Default Visual Studio MVC Website</a> </li>
<li sizcache="0" sizset="12"><a href="#UsefulLinks">Useful Links</a> </li>
</ul>
<p sizcache="0" sizset="11">&#160;</p>
<h3 sizcache="0" sizset="13"><a name="BeforeYouBegin">Before you Begin</a></h3>
<p sizcache="0" sizset="14">There are a few things you need to download before you get started.&#160; First of all, you’ll need an SSH client for file transfer and console access. I’m using <a href="http://filezilla-project.org/download.php" target="_blank">FileZilla</a> and <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" target="_blank">Putty</a> as my SSH clients. If you’ve never used it before, think of SSH like telnet and FTP wrapped into one.</p>
<p>Here’s a few tips on navigating the text mode installer screens. Use the Tab Key to cycle through fields or change focus between sections on the screen. Use the Spacebar or Enter to select an option. Esc can back out of a dropdown option. You can use the arrow keys to cycle options in a section.</p>
<p sizcache="0" sizset="16">Download one of the <a href="http://software.opensuse.org/112/en" target="_blank">installers on OpenSuse’s website.</a> Burn or mount the ISO and boot your machine from it to begin.</p>
<p><em>Note: while I was doing this on a test virtual machine, I could only get the Network install to work with Virtual PC 2007 on my hardware. All the versions worked fine when installing it to a physical machine. If you choose the network install, you may need to configure your DHCP settings before the GUI installer starts. (with Virtual PC, make sure the correct external network card is exposed to the virtual machine). </em></p>
<h3 sizcache="0" sizset="17"><a name="InstallingLinuxPart1">Installing Linux Graphical (part 1)</a></h3>
<p>In sequence, here are (most) of the screens you’ll see during the first part of installing OpenSuse 11.2.</p>
<div class="gallery" sizcache="0" sizset="18">
<table border="0" cellpadding="5" sizcache="0" sizset="18">
<tbody sizcache="0" sizset="18">
<tr sizcache="0" sizset="18">
<td width="269" sizcache="0" sizset="18"><a title="OpenSuse 11.2 boot screen" href="/resources/p441/install/1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OpenSuse Boot Screen" border="0" alt="OpenSuse Boot Screen" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/1.jpg" width="244" height="184" /></a></td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="19">
<td width="269" sizcache="0" sizset="19"><a title="Language selection" href="/resources/p441/install/2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Language selection" border="0" alt="Language selection" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/22.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Language selection</p>
</td>
</tr>
<tr sizcache="0" sizset="20">
<td width="269" sizcache="0" sizset="20"><a title="New install. Disable Auto-configuration" href="/resources/p441/install/3.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="New install. Disable auto-configuration." border="0" alt="New install. Disable auto-configuration." src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/3.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Uncheck<strong> </strong><em>Use Automatic Configuration</em></p>
</td>
</tr>
<tr sizcache="0" sizset="21">
<td width="269" sizcache="0" sizset="21"><a title="Choose your time zone" href="/resources/p441/install/4.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Choose your time zone" border="0" alt="Choose your time zone" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/41.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Choose your time zone.</p>
</td>
</tr>
<tr sizcache="0" sizset="22">
<td width="269" sizcache="0" sizset="22"><a title="Desktop selection. See options." href="/resources/p441/install/5.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Desktop selection" border="0" alt="Desktop selection" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/51.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>I chose minimal server.</p>
<p><strong>Optional:</strong> You may choose a desktop if you wish to use remote VNC to remotely admin your server with a GUI.&#160; VNC is kind of like using Remote Desktop. To do that, choose your desktop here, and we’ll configure it to still boot to text mode later at the summary screen.</p>
</td>
</tr>
<tr sizcache="0" sizset="23">
<td width="269" sizcache="0" sizset="23"><a title="Partition selection. I used defaults." href="/resources/p441/install/6.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Partition selection" border="0" alt="Partition selection" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/61.jpg" width="244" height="199" /></a></td>
<td width="375">Partition selection. I used defaults.</td>
</tr>
<tr sizcache="0" sizset="24">
<td width="269" sizcache="0" sizset="24"><a title="Setting up the first user. Uncheck Automatic Login." href="/resources/p441/install/7.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Setting up the first user" border="0" alt="Setting up the first user" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/71.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Enter your username. Uncheck automatic login.</p>
<p><strong>Optional:</strong> You may choose a different password for the root user.&#160; This is good if you have a public server sitting in the cloud in case someone gets the password to your normal user account.</p>
</td>
</tr>
<tr sizcache="0" sizset="25">
<td width="269" sizcache="0" sizset="25"><a title="Summary. Enable SSH." href="/resources/p441/install/8.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Summary" border="0" alt="Summary" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/81.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Summary screen. Scroll to the bottom.<strong> Click “enable and open” for Firewall and SSH</strong>. We’ll use SSH to remotely admin the server.</p>
<p><strong>Optional: </strong>If you chose a desktop earlier, change the <em>Default Runlevel </em>to 3 (Full multiuser with network). This will cause the server to boot to normal text mode by default.</p>
</td>
</tr>
<tr sizcache="0" sizset="26">
<td width="269" sizcache="0" sizset="26"><a title="Confirm Installation" href="/resources/p441/install/9.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Confirm Installation" border="0" alt="Confirm Installation" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/91.jpg" width="244" height="199" /></a></td>
<td width="375">
<p>Click Install to continue.</p>
</td>
</tr>
<tr sizcache="0" sizset="27">
<td width="269" sizcache="0" sizset="27"><a title="Progress" href="/resources/p441/install/12.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Installation Progress" border="0" alt="Installation Progress" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/121.jpg" width="244" height="199" /></a></td>
<td width="375">&#160;</td>
</tr>
</tbody>
</table></div>
<h3 sizcache="0" sizset="28"><a name="InstallingLinuxPart2">Configuring Linux During Install (part 2)</a></h3>
<p>After the first phase, your computer will reboot and begin the manual configuration phase. As I mentioned earlier, these screens are pretty easy to navigate. Use tab to cycle through the fields or change focus to different sections. Use space or enter to make a selection. Also, the highlighted letters in words are hotkeys you can use in combination with the Alt key.&#160; Each section will continue when you select the NEXT option in the bottom right corner.</p>
<div class="gallery" sizcache="0" sizset="29">
<table border="0" cellpadding="5" sizcache="0" sizset="29">
<tbody sizcache="0" sizset="29">
<tr sizcache="0" sizset="29">
<td valign="top" width="269" sizcache="0" sizset="29"><a title="First configuration screen. Enter your hostname" href="/resources/p441/config/1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="First configuration screen. Enter your hostname" border="0" alt="First configuration screen. Enter your hostname" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/11.jpg" width="244" height="184" /></a> </td>
<td width="375">
<p>This is the first configuration screen. Enter your new machine hostname (or leave it default).</p>
</td>
</tr>
<tr sizcache="0" sizset="30">
<td valign="top" width="269" sizcache="0" sizset="30"><a title="Progress after choosing hostname." href="/resources/p441/config/2.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Progress screen" border="0" alt="Progress screen" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/21.jpg" width="244" height="184" /></a> </td>
<td width="375">
<p>Showing hostname configuration progress.</p>
</td>
</tr>
<tr sizcache="0" sizset="31">
<td valign="top" width="269" sizcache="0" sizset="31"><a title="Configuration screen. Choose Network Interfaces" href="/resources/p441/config/3.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Main configuration screen. Choose netowrk interface" border="0" alt="Main configuration screen. Choose netowrk interface" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/31.jpg" width="244" height="183" /></a> </td>
<td width="375">
<p>This is the main configuration screen. You will set your network configuration here. Tab until you see the bounding box around the gray area light up. Then down arrow to Network Interfaces. Press enter to select it.</p>
</td>
</tr>
<tr sizcache="0" sizset="32">
<td valign="top" width="269" sizcache="0" sizset="32"><a title="Network Interface screen." href="/resources/p441/config/4.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Network interfaces screen" border="0" alt="Network interfaces screen" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/4.jpg" width="244" height="183" /></a> </td>
<td width="375">
<p><strong>Overview Screen</strong></p>
<p>This is the first Network Interfaces screen. There are three focus areas. The first is the top tab area: Overview, Hostname/DNS, and Routing.</p>
<p>Tab to the interface list and select your interface card for your main Internet connection. Then press Alt-i to view its details</p>
</td>
</tr>
<tr sizcache="0" sizset="33">
<td valign="top" width="269" sizcache="0" sizset="33"><a title="Shows ethernet settings. Leave as DHCP or set to static." href="/resources/p441/config/5.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Ethernet NIC settings" border="0" alt="Ethernet NIC settings" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/5.jpg" width="244" height="184" /></a> </td>
<td width="375">
<p>Shows Ethernet details. If you choose to use static IP, this is where to set that information. Set the IP address, subnet, etc. You may leave this as DHCP if you wish.&#160; When you’re done tab and select Next.</p>
</td>
</tr>
<tr sizcache="0" sizset="34">
<td valign="top" width="269" sizcache="0" sizset="34"><a title="Set hostname/DNS" href="/resources/p441/config/7.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Set hostname and DNS" border="0" alt="Set hostname and DNS" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/7.jpg" width="244" height="184" /></a> </td>
<td width="375">
<p>From the Overview screen (bolded above), move to the Hostname/DNS section. Set your hostname and your DNS servers (if you chose static IP in the previous step).</p>
</td>
</tr>
<tr sizcache="0" sizset="35">
<td valign="top" width="269" sizcache="0" sizset="35"><a title="Routing configuration" href="/resources/p441/config/8.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Routing configuration" border="0" alt="Routing configuration" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/8.jpg" width="244" height="183" /></a> </td>
<td width="375">
<p>If you chose a static IP, tab from the Overview Screen to Routing. Set your default gateway and associate it with the correct device.</p>
</td>
</tr>
<tr sizcache="0" sizset="36">
<td valign="top" width="269" sizcache="0" sizset="36"><a title="Writing network configuration." href="/resources/p441/config/9.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Writing network configuration" border="0" alt="Writing network configuration" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/9.jpg" width="244" height="183" /></a> </td>
<td width="375">After clicking Next from the Overview Screen, the configuration changes will be written to disk. </td>
</tr>
<tr sizcache="0" sizset="37">
<td valign="top" width="269" sizcache="0" sizset="37"><a title="Test Internet Connection" href="/resources/p441/config/10.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Test Internet" border="0" alt="Test Internet" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/10.jpg" width="244" height="185" /></a> </td>
<td width="375">This step will test your Internet connection. If successful, it will check for updates. </td>
</tr>
<tr sizcache="0" sizset="38">
<td valign="top" width="269" sizcache="0" sizset="38"><a title="Successful connection" href="/resources/p441/config/11.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Successful connection" border="0" alt="Successful connection" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/111.jpg" width="244" height="184" /></a> </td>
<td width="375">Successful connection</td>
</tr>
<tr sizcache="0" sizset="39">
<td valign="top" width="269" sizcache="0" sizset="39"><a title="Updating packages" href="/resources/p441/config/12.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Updating packages" border="0" alt="Updating packages" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/12.jpg" width="244" height="184" /></a> </td>
<td width="375">Updating packages</td>
</tr>
<tr sizcache="0" sizset="40">
<td valign="top" width="269" sizcache="0" sizset="40"><a title="Updating packages" href="/resources/p441/config/13.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Updating packages" border="0" alt="Updating packages" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/13.jpg" width="244" height="183" /></a> </td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="41">
<td valign="top" width="269" sizcache="0" sizset="41"><a title="Run updates" href="/resources/p441/config/14.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Run updates" border="0" alt="Run updates" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/14.jpg" width="244" height="184" /></a> </td>
<td width="375">Run updates</td>
</tr>
<tr sizcache="0" sizset="42">
<td valign="top" width="269" sizcache="0" sizset="42"><a title="Package updates" href="/resources/p441/config/15.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Package updates" border="0" alt="Package updates" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/15.jpg" width="244" height="184" /></a> </td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="43">
<td valign="top" width="269" sizcache="0" sizset="43"><a title="Downloading updates" href="/resources/p441/config/16.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Downloading updates" border="0" alt="Downloading updates" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/16.jpg" width="244" height="183" /></a> </td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="44">
<td valign="top" width="269" sizcache="0" sizset="44"><a title="Installing updates" href="/resources/p441/config/17.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Installing updates" border="0" alt="Installing updates" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/17.jpg" width="244" height="184" /></a> </td>
<td width="375">Will reboot after this step. You may need to click Next after it finishes.</td>
</tr>
<tr sizcache="0" sizset="45">
<td valign="top" width="269" sizcache="0" sizset="45"><a title="After reboot, next config screen." href="/resources/p441/config/18.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="After reboot, next config screen." border="0" alt="After reboot, next config screen." src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/18.jpg" width="244" height="183" /></a> </td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="46">
<td valign="top" width="269" sizcache="0" sizset="46"><a href="/resources/p441/config/19.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="" border="0" alt="" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/19.jpg" width="244" height="184" /></a> </td>
<td width="375">&#160;</td>
</tr>
<tr sizcache="0" sizset="47">
<td valign="top" width="269" sizcache="0" sizset="47"><a title="Printer setup" href="/resources/p441/config/20.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Printer setup" border="0" alt="Printer setup" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/20.jpg" width="244" height="183" /></a> </td>
<td width="375">I used defaults here. </td>
</tr>
<tr sizcache="0" sizset="48">
<td valign="top" width="269" sizcache="0" sizset="48"><a title="Finally!" href="/resources/p441/config/21.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Finally!" border="0" alt="Finally!" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/211.jpg" width="244" height="184" /></a> </td>
<td width="375">Finally done! </td>
</tr>
<tr sizcache="0" sizset="49">
<td valign="top" width="269" sizcache="0" sizset="49"><a title="Console after installation" href="/resources/p441/config/22.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Console after installation" border="0" alt="Console after installation" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/221.jpg" width="244" height="183" /></a> </td>
<td width="375">The installation drops you to a console.&#160; </td>
</tr>
</tbody>
</table></div>
<p>&#160;</p>
<h3 sizcache="0" sizset="50"><a name="ConfiguringLinuxAfterInstall">Configuring Linux After Install</a></h3>
<div class="gallery" sizcache="0" sizset="51">
<p sizcache="0" sizset="51"><a title="Putty, open a connection to your new server." href="/resources/p441/post_install/1.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Putty, open connection" border="0" alt="Putty, open connection" align="right" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/113.jpg" width="244" height="234" /></a> At this point, your operating system is installed and accessible online via SSH. (If you purchased a VM, this is where you’ll usually begin). To connect to your new server, open Putty and enter your static IP or hostname for your new server. Select SSH connection type. Then click Open. You will be prompted to trust the certificate. Click YES, and login to your new server using the account you setup during install.</p>
<p sizcache="0" sizset="47"><em>NOTE: (You may optionally save these connection settings by typing a name and clicking Save. </em></p>
</p></div>
<p><strong>Root Access      <br /></strong>You’ll need root access to perform most of the tasks we’re doing, so enter: <strong>su</strong><em>, </em>then type the root password you configured during install. The command prompt will change color to <strong><font color="#ff0000">red</font></strong>.</p>
<h3 sizcache="0" sizset="52"><a name="UpdatingSoftware">Updating Software</a></h3>
<p>One of the really cool things about most Linux distributions is their package management. It’s a one-stop-shop for installing, updating, and removing software on your system. Fedora has <em>yum</em>, Debian has <em>apt-get</em>, OpenSuse has<em> </em><em>zypper</em>. Using these utilities is very straight forward. So if you didn’t update your system during install, you can do it now by entering:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">zypper update</pre>
<p>You can run this command occasionally to update your system. To see more details about how to use it. Enter: man zypper</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="53"><a name="InstallMonoAndApache">Install Mono, Apache, and MySql</a></h3>
<p sizcache="0" sizset="49"><strong>Installing Mono and Apache</strong></p>
<p sizcache="0" sizset="49">With zypper, we can cheat a little to install mono, apache, and all dependencies. First we need to add the mono repositories so zypper knows how to find it.</p>
<p sizcache="0" sizset="49">Enter the following lines separately:</p>
<pre class="brush: bash; gutter: false;">zypper addrepo http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.2 mono-stable
zypper refresh --repo mono-stable
zypper dist-upgrade --repo mono-stable</pre>
<p sizcache="0" sizset="49">Our cheat is going to be installing Mod_Mono, which is the mono plugin for Apache. This will force it to install apache, mono, xsp and everything we need to get started.</p>
<pre class="brush: bash; gutter: false; toolbar: false;">zypper install mod_mono</pre>
<p><strong>Autostart Apache</strong></p>
<p>To make apache start when the system reboots, enter this command:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">chkconfig --add apache2</pre>
<p><strong>Installing MySql Server</strong></p>
<p>To download and install mysql server and client, enter this command:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">zypper install mysql</pre>
<p>Add MySql to your startup and start it:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">chkconfig --add mysql

service mysql start</pre>
<p>Then configure the server with:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">mysql_secure_installation</pre>
<p>Follow the instructions and setup your server. The first question will be to enter your root password; the first time you run this, just press enter with a blank password, then choose <strong>Y</strong> to enter a new root password. You’ll also want to disable remote root access, the anonymous user, and test database.</p>
<p><strong>Optional:</strong></p>
<p>Now setup your user account so you can remotely access the server. This also requires you to expose your MySql server over the Internet if you’re running a hosted server. Users in MySql are username &amp; host based. Both parts make up a unique user.</p>
<p><strong>To add a user:</strong></p>
<p>Connect to your database server using your new root password. Enter: <strong>mysql -p</strong></p>
<p>Here is an example of a user you would typically use for a specific application running on the local machine. This statement grants all privileges on a database called test_database and all its tables to a username ‘my_new_username’ who can only connect from localhost.</p>
<pre class="brush: sql; gutter: false;">grant all privileges on test_database.* to 'my_new_username'@'localhost' identified by 'new_password' with grant option;</pre>
<p>An admin user with access to everything from any location would have a statement similar to this:</p>
<pre class="brush: sql; gutter: false;">grant all privileges on *.* to 'super_user'@'%' identified by 'super_secret_pw' with grant option;</pre>
<p>Enter <strong>quit</strong> to exit the MySql client.</p>
<p><strong>Firewall </strong></p>
<p>This is actually much simpler than it looks. I’m showing all these screens just for reference. Basically, just use yast as the tool configure the firewall. It has a nice little interface similar to the post-install configuration. For what we’re doing, add your network device to the External Zone, then add Secure Shell Server and HTTP Web Server to the allowed services. Then just enable and turn on your firewall (if it isn’t already on)</p>
<div class="gallery" sizcache="0" sizset="54">
<table border="0" cellpadding="5" sizcache="0" sizset="54">
<tbody sizcache="0" sizset="54">
<tr sizcache="0" sizset="54">
<td valign="top" width="269" sizcache="0" sizset="54"><a title="Start yast." href="/resources/p441/post_install/6.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Start Yast" border="0" alt="Start Yast" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/6.jpg" width="244" height="154" /></a> </td>
<td width="375">Enter: <strong>yast</strong></td>
</tr>
<tr sizcache="0" sizset="55">
<td valign="top" width="269" sizcache="0" sizset="55"><a title="Go to interface configuration" href="/resources/p441/post_install/7.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Interface configuration" border="0" alt="Interface configuration" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/72.jpg" width="244" height="154" /></a> </td>
<td width="375">Navigate to Interfaces, set your network device to be in the External Zone. </td>
</tr>
<tr sizcache="0" sizset="56">
<td valign="top" width="269" sizcache="0" sizset="56"><a title="Add allowed sevices" href="/resources/p441/post_install/8.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Allowed Services" border="0" alt="Allowed Services" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/82.jpg" width="244" height="155" /></a> </td>
<td width="375">Navigate to Allowed Services, select External Zone, then select Secure Shell Server. </td>
</tr>
<tr sizcache="0" sizset="57">
<td valign="top" width="269" sizcache="0" sizset="57"><a title="Add each service individually" href="/resources/p441/post_install/9.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add each service individually" border="0" alt="Add each service individually" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/92.jpg" width="244" height="155" /></a> </td>
<td width="375">
<p>Use the Add link to add the selected service to the list.</p>
<p><strong>Repeat this for HTTP server</strong>.</p>
<p><strong>Optional:</strong> Add MySql server if you want to expose it to the Internet and access it remotely with your tools.</p>
</td>
</tr>
<tr sizcache="0" sizset="58">
<td valign="top" width="269" sizcache="0" sizset="58"><a title="Enable and start the firewall" href="/resources/p441/post_install/10.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Enable and start the firewall" border="0" alt="Enable and start the firewall" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/101.jpg" width="244" height="155" /></a> </td>
<td width="375">Enable and Start your firewall from the Start Up screen. </td>
</tr>
<tr sizcache="0" sizset="59">
<td valign="top" width="269" sizcache="0" sizset="59"><a title="Finish" href="/resources/p441/post_install/11.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Finish" border="0" alt="Finish" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/114.jpg" width="244" height="155" /></a> </td>
<td width="375">Finish</td>
</tr>
</tbody>
</table>
</div>
<p><strong></strong></p>
<p>&#160;</p>
<h3 sizcache="0" sizset="60"><a name="ConfigureApache">Configure a Virtual Host &amp; Web Directory</a></h3>
<p sizcache="0" sizset="61">I used the <a href="http://go-mono.com/config-mod-mono/" target="_blank">Mod_Mono configuration tool</a> on the Mono website, which built the following configuration file. It looks big, but most of it’s comments. The key notes here are that it runs .Net 2.0, it’s root directory and that it handles all requests through Mono (good for MVC). It also does some nice things like compress the output on certain files as well as the Mono output.</p>
<div class="gallery" sizcache="0" sizset="62">
<p sizcache="0" sizset="62"><a title="Using the Mod_Mono configuration tool." href="/resources/p441/post_install/14.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="Using the Mod_Mono configuration tool" border="0" alt="Using the Mod_Mono configuration tool" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/141.jpg" width="216" height="244" /></a></p>
</div>
<p sizcache="0" sizset="61">&#160;</p>
<pre class="brush: xml; gutter: false; toolbar: false;">&lt;VirtualHost *:80&gt;
  ServerName odin.integratedwebsystems.int
  ServerAdmin web-admin@odin.integratedwebsystems.int
  DocumentRoot /srv/www/odin.integratedwebsystems.int
  # MonoServerPath can be changed to specify which version of ASP.NET is hosted
  # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0
  # For SUSE Linux Enterprise Mono Extension, uncomment the line below:
  # MonoServerPath odin.integratedwebsystems.int &quot;/opt/novell/mono/bin/mod-mono-server2&quot;
  # For Mono on openSUSE, uncomment the line below instead:
  MonoServerPath odin.integratedwebsystems.int &quot;/usr/bin/mod-mono-server2&quot;

  # To obtain line numbers in stack traces you need to do two things:
  # 1) Enable Debug code generation in your page by using the Debug=&quot;true&quot;
  #    page directive, or by setting &lt;compilation debug=&quot;true&quot; /&gt; in the
  #    application's Web.config
  # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging
  MonoDebug odin.integratedwebsystems.int true

  # The MONO_IOMAP environment variable can be configured to provide platform abstraction
  # for file access in Linux.  Valid values for MONO_IOMAP are:
  #    case
  #    drive
  #    all
  # Uncomment the line below to alter file access behavior for the configured application
  MonoSetEnv odin.integratedwebsystems.int MONO_IOMAP=all
  #
  # Additional environtment variables can be set for this server instance using
  # the MonoSetEnv directive.  MonoSetEnv takes a string of 'name=value' pairs
  # separated by semicolons.  For instance, to enable platform abstraction *and*
  # use Mono's old regular expression interpreter (which is slower, but has a
  # shorter setup time), uncomment the line below instead:
  # MonoSetEnv odin.integratedwebsystems.int MONO_IOMAP=all;MONO_OLD_RX=1

  MonoApplications odin.integratedwebsystems.int &quot;/:/srv/www/odin.integratedwebsystems.int&quot;
  &lt;Location &quot;/&quot;&gt;
    Allow from all
    Order allow,deny
    MonoSetServerAlias odin.integratedwebsystems.int
    SetHandler mono
    SetOutputFilter DEFLATE
    SetEnvIfNoCase Request_URI &quot;\.(?:gif|jpe?g|png)$&quot; no-gzip dont-vary
  &lt;/Location&gt;
  &lt;IfModule mod_deflate.c&gt;
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
  &lt;/IfModule&gt;
&lt;/VirtualHost&gt;</pre>
<p sizcache="0" sizset="63">Edit the information above (or use the <a href="http://go-mono.com/config-mod-mono/" target="_blank">configuration tool</a>) and replace my hostname with yours. Then save this file with the extension “.conf” and copy it to your /etc/apache2/conf.d directory using <a href="http://filezilla-project.org" target="_blank">FileZilla</a> SFTP connection as the root user.</p>
<p>Create a new directory at the location you specified in the DocumentRoot command. This is the root folder you’ll use to deploy your website.</p>
<pre class="brush: bash; gutter: false; toolbar: false;">cd /srv/www

mkdir my_web_hostname</pre>
<p>After setting all this up, you’ll need to restart your Apache server. To do that, just enter:</p>
<pre class="brush: bash; gutter: false; toolbar: false;">service apache2 restart</pre>
<p>You can restart any of your services this way. You might also reboot your server just to get a fresh run after installing and configuring all our software. Use the shutdown command to restart your system. Again, you can use <em>shutdown &#8211;help</em> or <em>man shutdown</em> to learn more about that command.</p>
<pre class="brush: bash; gutter: false; toolbar: false;">shutdown -r now</pre>
<h3 sizcache="0" sizset="65"><a name="RunningMVC">Running the Default Visual Studio MVC Website</a></h3>
<div class="gallery" sizcache="0" sizset="66">
<p sizcache="0" sizset="66"><a title="Running default MVC website on Apache/Mono 2.6.1" href="/resources/p441/post_install/13.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="It works! " border="0" alt="It works! " align="right" src="http://www.integratedwebsystems.com/wp-content/uploads/2010/01/131.jpg" width="244" height="120" /></a> Open Visual Studio 2008 and build a brand new ASP.NET MVC Web Application.&#160; Publish it to a folder and copy all the published contents to your Linux server at <em>/srv/www/my_web_hostname</em> using FileZilla. Using a web browser, browse to your server and it should show that the new web application works right out the box (with the exception of Membership).</p>
</div>
<p sizcache="0" sizset="67">This is cool! It’s a great start knowing that routing, controllers and views all work. Feel free to play with it a bit more. Mono has some great tools like <a href="http://www.mono-project.com/MoMA" target="_blank">MoMa</a> that will tell you if your existing assemblies are compatible with Mono. You can also start toying around with Dblinq and alternative membership providers.</p>
<p>&#160;</p>
<p sizcache="0" sizset="68">There’s more to come. The <a href="http://www.integratedwebsystems.com/2010/02/how-to-setup-and-configure-mysql-membership-provider-6-2-2-porting-to-mono-part-2-of-3/">next post</a> will show you how to use the <a href="http://dev.mysql.com/downloads/connector/net/#downloads" target="_blank">MySql Membership</a> provider with both Windows and Mono.</p>
<p>&#160;</p>
<h3 sizcache="0" sizset="69"><a name="UsefulLinks">Useful Links</a></h3>
<ul sizcache="0" sizset="70">
<li sizcache="0" sizset="70">Mono Website – <a title="http://www.mono-project.com" href="http://www.mono-project.com">http://www.mono-project.com</a>&#160; </li>
<li sizcache="0" sizset="71">Mod_Mono Configuration Tool &#8211; <a href="http://go-mono.com/config-mod-mono/">http://go-mono.com/config-mod-mono/</a> </li>
<li sizcache="0" sizset="72">MoMa&#160; Mono Compatibility Checker &#8211; <a title="http://www.mono-project.com/MoMA" href="http://www.mono-project.com/MoMA">http://www.mono-project.com/MoMA</a> </li>
<li sizcache="0" sizset="73">OpenSuse 11.2 Download Page (scroll down) &#8211; <a href="http://software.opensuse.org/112/en">http://software.opensuse.org/112/en</a> </li>
<li sizcache="0" sizset="74">OpenSuse Documentation (loaded with great how to documents) &#8211; <a href="http://en.opensuse.org/Documentation">http://en.opensuse.org/Documentation</a> </li>
<li sizcache="0" sizset="75">Putty Download Page &#8211; <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html</a> </li>
<li sizcache="0" sizset="76">FileZilla Download Page &#8211; <a href="http://filezilla-project.org/download.php">http://filezilla-project.org/download.php</a> </li>
<li sizcache="0" sizset="77">MySql Connector .NET Download &#8211; <a title="http://dev.mysql.com/downloads/connector/net/#downloads" href="http://dev.mysql.com/downloads/connector/net/#downloads">http://dev.mysql.com/downloads/connector/net/#downloads</a> </li>
<li sizcache="0" sizset="78">MySql Workbench (MySql Administration and Development tools) &#8211; <a title="http://dev.mysql.com/downloads/workbench/5.2.html" href="http://dev.mysql.com/downloads/workbench/5.2.html">http://dev.mysql.com/downloads/workbench/5.2.html</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.integratedwebsystems.com/2010/01/installing-opensuse-11-2-with-mono-2-6-1-and-apache-using-text-mode-configuration-porting-to-mono-part-1-of-3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
