I have created my first ever video tutorial which I am showing to the world. I walked through my post “How to get ASP.NET MVC 2 working with Mono in 10 Steps“. I plan to make more videos in the future so future ones should be better.
There is a video at the end of this post walking through it.
Once you get it figured out its easy. I always like to try to get my asp.net apps to run on mono so that I can say they can. The itch to do that with MVC 2 came back around a week ago, and I thought like every other time it was going to be simple. After some good googling I came up short, except to learn that MVC 2 is in the core of 2.7 and in the core of 2.8
preview. (Updated Post Since Official Release of 2.8)
I am a person that has never had luck installing mono from source, until today. So this was an adventure that took me probably 8 hours to figure out from start to end, and something I can redo now in about 30 minutes, including compile time.
I am going to list all my steps and why so you can know what is going on too. These are the steps on a complete fresh install of Ubuntu 10.04 Server, after updating it.
Step 1: Dependencies
apt-get install build-essential bison gettext pkg-config autoconf libtool automake
build-essential, bison, and gettext are required for the actual compilation of the source code. Fortunately, if you don’t install one of them it will complain at you and tell you what you don’t have.
pkg-config, autoconf, libtool, and automake are required for mono itself and running the configuration even before compilation. If you don’t do this step it too will complain at you.
Step 2: Compile and Install Mono from Source
tar -xjvf mono-2.8.tar.bz2
The above is pretty basic and easy to understand. Just note the –prefix=/usr there so it installs all the mono apps to /usr/bin. I made the mistake of doing –prefix=/usr/bin/ and it installed everything /usr/bin/bin. It was not pretty trying to fix the problem.
Step 3: Compile and Install XSP Server
tar -xjvf xsp-2.8.tar.bz2
This creates several of the things you need to run your ASP.NET applications. Of note for later it creates the application mod-mono-server4 which is what you will use to run your MVC 2 application on the .NET 4.0 framework.
Step 4: Install Apache
apt-get install apache2 apache2-dev
Now it is time to install apache, if it isn’t installed already. Also be sure to install the apache2-dev package since mod_mono needs it.
Step 5: Compile and Install mod_mono
tar -xjvf mod_mono-2.8.tar.bz2
Just like above this is pretty normal. Specifically what this does is it creates a config file for apache and the apache module. It puts the mod-mono.so module in the correct place, but not the apache config file.
Step 6: Fix mod_mono.conf File Location
mv /etc/apache2/mod_mono.conf /etc/apache2/mods-available/
This will put the file in the correct location. At this point we should be able to do ‘a2enmod mod_mono’, but it doesn’t seem to work. I didn’t move this to the mods-enabled folder because I wanted to keep with convention.
Step 7: Setup Symlink to Enable Site mod_mono
ln -s /etc/apache2/mods-available/mod_mono.conf /etc/apache2/mods-enabled/mod_mono.conf
a2enmod creates a symlink to files from /etc/apache2/mods-available/ to /etc/apache2/mods-enabled. This is a good convention to hold on to so the above line does just that.
Step 8: Letting Apache take Hold of Changes
Everything “should” load up normally at this point. If not read through the output and see if you can’t figure out what isn’t correct.
Step 9: Setting Up Virtual Host
This is a normal vhost file you would use anywhere with ASP.NET. The only difference for the ability to render MVC 1 and 2 is the MonoServerPath line. The end of it should point to mod-mono-server4 instead of 1 or 2*. If you don’t change this you will probably get a “targetFramework” error with your web.config file.
Just drop your MVC 2 app in “/srv/www/net.example.net/public_html/” and move on to the next step.
*.NET 1.1 support has been dropped with this latest release so mod-mono-server1 probably wont be there.
Step 10: Getting it all Working
Now is time to reload the apache vhost configurations. This assumes you have a virtualhost file loaded and ready to go. For the first install of mono I like to just restart apache.
At this point you should be able to browse your MVC 2.0 app, from the URL you set. It was quite a thrill to get it working the first time. For a test I made an MVC 2.0 app in Visual Studio 2010 built it. Then copied all the files over the server and it worked out of the box, once the above 10 steps were done.
I hope this helps other people and it works for them. It was a lot of fun and I learned a lot getting this working. If you have any questions please feel free to ask.
woohoo. I finally got monodevelop installed on my laptop in crux.
What a bear of a job. I spent a few days wondering why in the world it wouldn’t start. Then miraculously I tried to start it through console and it spit out that it needed MOZILLA_FIVE_HOME variable set to Mozilla installation directory. Well that sucked because I had not idea what program it was referring to. Whether it meant a specific one or the whole freaking package.
So after a day of griping and complaining and google searches I finally decided to just download the 13 meg mozilla file and untar it. Well once I finally did that I set the environment variable like so:
After that it worked. Now I need to figure out why it says Version .8 and not version 0.7. Oh, well at least I have it installed now and can play with it.
Until next time happy coding.
Ok, I have been messing with the Mono project for a bit now, and I must say I find it a bit difficult, to say the least. I’m hoping to get into some gnome development with it. I think that would be fun. My biggest problem is understanding this whole widgets concepts it boggles my mind.
If any Microsoft .NET people have messed with Mono at all please leave a comment on here, and if you have a blog please leave the address so I can subscribe to it.
Now some of you maybe wondering why I went from being so Hardcore MS to using Linux. I want to answer that right now. I still am Hardcore MS. I love the company and still want to work there, but I also like to mess with stuff that is challenging and right now Linux is really kicking my butt so it intrigues me.
I really need to get back to my ASP.NET programming. I just need to find my VS.NET demo cd so I can install it and use it again, man I wish I had the money for the full version. Anyway back to being abused by Linux.
p.s. Still need help finding good XSLT tutorials let me know if you know of any.