Programming Blog

Jeremy Morgan

Mostly Coherent Ramblings of a Silicon Forest Software Developer

How to Install ASP.Net 5 on Ubuntu Linux

By: Jeremy Morgan







C# Newsletter


One of the primary goals of the ASP.Net 5 (codenamed vNext) project is cross platform development, and it’s become easier than ever to develop ASP.Net applications on Linux and OSX. Today we’re going to take a look at how to do this with Ubuntu Linux server.

1. Get Your System Ready

Let’s get our system started. For this tutorial I’m using a Digital Ocean droplet. These are only $5 per month, and if you click this link to sign up you’ll get a $10 credit.

I installed a blank Ubuntu 14.04 64 bit server. First, run the following:

1
sudo apt-get update&&sudo apt-get dist-upgrade

This will make sure we have the newest package lists and upgrade packages if they are available.

Next we’ll need to install Mono. The current stable version for Ubuntu is 3.2.8, which won’t run ASP.Net, so we will have to pull it directly from the Mono repositories:

1
2
3
4
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete

To make sure it installed correctly, type in

1
mono -V

Next, we’ll install some prerequisites that we’ll need to fetch and build some items from source:

1
sudo apt-get install -y autoconf build-essential git-core libtool unzip curl

Also, to run web services we’ll need to install libuv. We’ll have to build it from source and link it:

1
2
3
4
5
6
7
8
cd /opt
sudo git clone https://github.com/libuv/libuv.git
cd libuv
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install
sudo ln -s /usr/local/lib/libuv.so /usr/lib/libuv.so.1

Now our system should be ready for ASP.Net 5.

2. Set up ASP.Net 5

Now that we’ve got that set up, let’s put ASP.Net 5 on here. First we’ll install KVM:

1
curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.k/kvm/kvm.sh

Note: if you want to go real bleeding edge, you can install DNVM instead, shich is the replacement for KVM:

1
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh

Now, let’s install DNX (the .Net execution environment)

1
kvm upgrade

If you downloaded DNVM above instead, run:

1
dnvm upgrade

3. Clone an ASP.Net Sample

Now we’ll clone the sample repositories:

1
2
3
4
mkdir ~/aspnet
cd ~/aspnet
git clone https://github.com/aspnet/Home.git
cd ~/aspnet/Home/samples/HelloMvc

This is the sample we’ll choose to build. Type in the following to build the packages for it:

1
kpm restore

Now we can start it up:

1
k kestrel

You should see a screen that looks like this:

Congrats! You now have ASP.Net 5 running on Ubuntu Linux!

If you would like to run this as a background process, type in

1
nohup k kestrel &

Note that this should not yet be used for production servers!


C# Newsletter


Conclusion

I have found several articles online about how to do this, but many of them seemed innaccurate, missing peices or out of date. This is common with bleeding edge stuff. I’ll try to update this as much as possible.

This is a good way to set up cheap instances of ASP.Net for your projects. At only $5 a month you could have several application servers running for your project for very little. As I stated before you can get a $10 credit from Digital Ocean by using this link to sign up, or you can use some of the other low cost Linux hosts out there to set up some low cost, fast ASP.Net 5 servers.

Enjoy!


Do you like articles like this?

I’m constantly hacking on stuff and writing about happenings in the programmer world. You can subscribe to my feed here, or you can get the hacker newsletter 100% spam free!

You can also follow my projects on GitHub:

Comments