BlogEngine in VMware with Mono on openSUSE

For Windows developers trying to diversify their skills and go Mono, setting up environment is probably the most painful experience. We spoiled by Microsoft tricked us into believe that setup and configuration done by repeatedly pressing “ok” button. It is not so in the wild world outside MS sandbox. For those bold and curious, as a first step I recommend another sandbox – VMware. Try it, see if you like it and, if not – not a big deal, just remove virtual image and pretend it never happened. No hard feelings.

Lets begin by getting [W:VMware]. I’m using Workstation, but free Player will do just fine. Set it up on Windows machine (have fun pushing those “ok” buttons).

Now go to Mono download page. You should see similar picture:

vmw-9.png 

Versions likely to be different by the time you read it, but you should be ok getting latest.

Get virtual image (Mono for VMware). When you download and unzip it, it will have 2 files. Simply double-click the one with extension .vmx and it will be loaded in the VMware virtual machine. Click start button and you got Linux, Apache and Mono installed and configured for you. Can’t get any simpler than that.

vmw-11.png

Before we move further, let’s take a look around to understand all important stuff we have here.

**/srv/www/htdocs** - is your web root.
**/usr/share/mono/asp.net/apps** – Mono sample applications and starter kits.
**/etc/apache2/conf.d** - place where Apache is looking for configuration files.
**/etc/xsp/2.0/applications-available** – Mono configuration files.

First things first – in Windows file explorer select blogengine web project (I renamed it to be131) and drag it into VMware straight to the web root(/srv/www/htdocs). Set write permission on App_Data folder – right click it andset permissions almost like you would in Windows. If you run into problem - let everybody do anything on that folder. This is what sandboxes for :) You might think you are ready to go straightto the browser, but that won’t work (itwould be way too easy). You need to tell Apache and Mono about new application they have to take care of.

vmw-12.png

In Apache, unlike IIS, you don’t have UI to set applications, virtual directories etc. Again, that would be too easy and no fun at all. Instead, you have configuration files and text editor. Let’s go ahead and edit those files. You’ll need to use root (admin) account. Start terminal window and type in “su root”, hit enter and, when prompted, “mono” as a password. Congratulations – you’ve just been promoted to almighty “root”. Now you can run any application from command line as administrator. Start text editor by typing “gedit” followed by file name you want to open. If file does not exist, Linux will create one for you.

>gedit /etc/apache2/conf.d/be131.conf

We need a new configuration file to tell apache where to find our application. We want it to look at physical directory “/srv/www/htdocs/be131” and map it to virtual path “/be131”, so that we can type “http://localhost/be131” to get to the site. Because Apache is going to use Mono module to run application, we need to supply a path to Mono configuration file and tell what .NET version to use (mod-mono-server2 for ASP.NET 2.0).

Copy and paste into the editor:

// /etc/apache2/conf.d/be131.conf
Alias /be131 /srv/www/htdocs/be131
MonoApplicationsConfigFile be131 /etc/xsp/2.0/applications-available/be131.webapp
MonoServerPath be131 "/usr/bin/mod-mono-server2"
MonoSetEnv be131 MONO_IOMAP=all
<Location /be131>
    Allow from all
    Order allow,deny
    SetHandler mono
    MonoSetServerAlias be131
</Location>

Save file and close editor window. Now create another configuration file that will ask Mono to take care about our application:

>gedit /etc/xsp/2.0/applications-available/be131.webapp

Mono also needs to know physical and virtual path to the application to work properly.

// /etc/xsp/2.0/applications-available/be131.webapp
<?xml version="1.0" ?>
<web-application>
  <name>be131</name>
  <vpath>/be131</vpath>
  <path>/srv/www/htdocs/be131</path>
  <enabled>true</enabled>
</web-application>

Save. Close. Having fun yet? Almost there, all we need to do is to restart Apache:

> rcapache2 restart

Now you can open browser and navigate to http://localhost/be131 - and you will be greeted with usual “welcome to BlogEngine” page.

vmw-10.png

Wasn’t all that hard, wasn’t it? Well, to be honest it is because imagewe used already had all hard work done for us – installing Apache andMono and configuring them to play together nicely. This is probably theeasiest way to get your feet wet with Mono and ASP.NET in general, not just BlogEngine. If you know better way or have some interesting input or run into a problem – don’thesitate to leave a message.

About RTUR.NET

This site is all about developing web applications with focus on designing and building open source blogging solutions. Technologies include ASP.NET Core, C#, Angular, JavaScript and more.