Hosting a NodeJs Express Application on Amazon Web Services (EC2)

For the past year or so I’ve been super intrigued by NodeJs. It’s a very cool stack, and the thought of building an entire application (front and back) with Javascript certainly merits some attention. Add MongoDb (a javascript based, document database) to that, and you have a nice, cohesive, high performance application.

Hosting your application is also super easy, especially if you choose a service like Heroku. Their service is ultra simple to use, and they support git deployments out of the box. But you may have reasons to not use a service like Heroku. It turns out that setting your application up on Amazon EC2 is not all that difficult. You can have the same git deployment functionality that Heroku supports, and you will have full control over the server running your application. So the price will be the same if you run ten applications or one application on the same server. You’ll also have local access to their whole array of AWS services, which is a plus.

Anyways, here’s a walkthrough on how to get a simple Node Express application up and running on Amazon EC2 with git push deployments. Continue reading

Install Mono 3.0.7 from Source on Ubuntu with a Bash Script

Like the other scripts I’ve posted, this one is meant to be a barebones mono install with the exception of LibGDI, LibGTK, XSP, and ModMono. You can easily make it a web server or just compile simple CLI scripts in mono. Run “csharp” for an interactive shell.

NOTE: Ubuntu 12.04 LTS and Badgerports.org are now current w/ 2.10.8.1. This bash script is more useful when installing parallel Mono, when a new version is released and not yet published on badgerports, or if you simply want to compile it yourself from source. I highly recommend trying the latest Ubuntu or Badgerports first.

This version installs Mono 3.0.7

Install

mkdir mono-3.0
cd mono-3.0
wget --no-check-certificate https://raw.github.com/nathanb/iws-snippets/master/mono-install-scripts/ubuntu/install_mono-3.0.sh
chmod 755 install_mono-3.0.sh
./install_mono-3.0.sh

Take note that this will install to the suggested parallel environments path at: /opt/mono-3.0. Adjust your environment accordingly in either your virtual host config or your CLI environment before using it to run your Mono apps.

Install Mono 2.11 from Source on Ubuntu with a Bash Script

NOTE: Ubuntu 12.04 LTS and Badgerports.org are now current w/ 2.10.8.1. This bash script is more useful when installing parallel Mono, when a new version is released and not yet published on badgerports, or if you simply want to compile it yourself from source. I highly recommend trying the latest Ubuntu or Badgerports first.

Updated Sept 11, 2012 – Incremented Mono to 2.11.3 (from 2.11.0).

Install

This script is meant to be a barebones web server install. Feel free to tweak the script and add as many packages as you like to it.

mkdir mono-2.11
cd mono-2.11
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.11.sh
chmod 755 install_mono-2.11.sh
./install_mono-2.11.sh

 

There is also a CentOS/Red Hat script in the GitHub repository.

Enjoy!

Get Started with Amazon EC2, Run Your .NET MVC3 (Razor) Site in the Cloud with Linux Mono

I’ve recently been getting pretty excited about Amazon EC2 once I realized you can setup a micro linux server for free to learn and test out their services. I know, a couple years behind the curve right? I’ve just never really looked into it. Now that I’m familiarizing myself with the whole cloud concept with Amazon, it’s really cool to think of small business growth potential in the web market without the restraint of building a heavy infrastructure upfront. I realize after reading some other articles that in the long run, it is probably more expensive than hosting your own solution. But as a startup, it still seems to me that it’s a pretty good deal at least for short term events or just taking their infrastructure out for a spin to test some ideas. Pay for what you use; that’s Amazon’s big pitch with their Amazon Web Services (AWS).

So if you want to play around with AWS for free, you have to roll Linux. If you want to host ASP.NET MVC3 on AWS Linux, there’s a few steps you need to take. For this post, I’ll talk about some of the AWS services that can get you started along with how to install and configure your environment for hosting ASP.NET MVC3 applications with Linux and Mono.

Continue reading

Running Mono MVC3 Razor and Solving the InvalidOperationException of ‘The view ‘name’ or its master was not found’

I’ve been fighting my system the past day or so trying to figure out why all the views in one of my controllers return this silly exception. The file indeed exists. Permissions are correct. Other controller views works. Other non-view (like json or file content) actions work within this controller. This works on Windows but not in Mono. Why doesn’t it work? To find this, I ended up using my source control to identify the commit that caused the break. Then line by line, I started toggling the changes within that commit until I found it.

System.InvalidOperationException: The view ‘Index’ or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Areas/Manage/Views/Dashboard/Index.aspx ~/Areas/Manage/Views/Dashboard/Index.ascx ~/Areas/Manage/Views/Shared/Index.aspx ~/Areas/Manage/Views/Shared/Index.ascx ~/Views/Dashboard/Index.aspx ~/Views/Dashboard/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Areas/Manage/Views/Dashboard/Index.cshtml ~/Areas/Manage/Views/Dashboard/Index.vbhtml ~/Areas/Manage/Views/Shared/Index.cshtml ~/Areas/Manage/Views/Shared/Index.vbhtml ~/Views/Dashboard/Index.cshtml ~/Views/Dashboard/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml

I’m saying this purely by observation. But MVC3 (or maybe the Mono runtime) seems to group compiled view code by controller. I was able to figure out that ALL ViewResult actions failed under this specific controller. It turns out I had one character out of place in my Razor syntax. With that one syntactical flaw, all the views under that controller could not compile and the only reasonable exception that could be thrown was the one above. The windows runtime seems to ignore this (maybe because it compiles them individually; I don’t know). In my case, I was trying to render one view when another view was causing the problem.

So if you see this exception and everything seems to be correct, start sifting through your recent View changes to see if anything you did broke the view syntax. So you can get a little laugh, here’s my goof up:

Extra @ symbol not needed when continuing a code block

The indicated ‘@’ symbol is not necessary when continuing additional statements.

Enjoy!

Install Mono 2.10.8 from Source on Ubuntu with a Bash Script

NOTE: Badgerports.org is now current w/ 2.10.8.1. This bash script is more useful when installing parallel Mono, when a new version is released and not yet published on badgerports, or if you simply want to compile it yourself from source. I highly recommend trying Badgerports first.

Install

mkdir mono-2.10
cd mono-2.10
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.10.sh
chmod 755 install_mono-2.10.sh
./install_mono-2.10.sh

 

Enjoy!

Update 12/30/2011 – Updated Mono 2.10.6 to 2.10.8.0

Update 10/16/2011 – Updated Mono 2.10.5 to 2.10.6

Update 8/31/2011 – Updated Mono 2.10.4 to 2.10.5

Update 8/11/2011 – Updated Mono 2.10.3 to 2.10.4 for minor update.

Get MVC3 Razor Running on Mono

Updated 10-18-2011 – added some more common issues

I dug around a little to figure this out. Hopefully this will clarify all the steps required to get an MVC 3 Razor site running on Mono. The main pitfall I ran into was gathering the additional dependencies and excluding Microsoft.Web.Infrastructure assembly from my deployment. Overall though it’s not too difficult to deploy your MVC3 app.

In Summary:

  1. Install Mono
  2. BIN Deploy Website
  3. Configure Apache (or Xsp environment)
  4. Fire Up Your Server
  5. Errors You Might See

Continue reading

Install Mono 2.10.2 and MonoDevelop 2.6 Beta 3 on Ubuntu With a Bash Script

After @migueldeicaza announced MonoDevelop Beta 3 a few days ago, I updated my scripts to install the new version. I’ve also included an upgrade script for those of you who used my Beta 2 script. The upgrade will uninstall the three Beta 2 projects and then download, compile and install the three new ones. I’ve only tested this so far on Ubuntu Natty (11.04), so let me know here if you have any problems with other versions.

 

 

Continue reading