ASP.NET MVC application on Linux? Easy!
As you may know, Microsoft recently released a lot of their products under MIT license. .NET Core runtime, .NET CoreFX, ASP.NET 5, MVC 6, Entity Framework 7, MSBuild, everything is now available on GitHub.
Our goal is: run Asp.Net MVC application with postgresql database on ubuntu server
Today we are gonna start with setting up .NET environment.
In the new asp.net stack you can choose between full .NET runtime and .NET Core. For now .NET Core has a lot of limitations, so we gonna use mono.
Install mono
As described in official documentation:
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
Install .NET Version Manager (DNVM)
First we need to install .NET Version Manager
We use the .NET Version Manager to install different versions of the .NET Execution Environment (DNX) (used by the ASP.NET 5 runtime) and switch between them.
curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.k/kvm/kvm.sh
Install the .NET Execution Environment (DNX)
kvm upgrade
This command will download the specified version of the DNX, and put it on your user profile ready to use. You are now ready to start using ASP.NET 5 with the DNX!
Compile and install libuv
sudo apt-get install gyp
wget http://dist.libuv.org/dist/v1.4.2/libuv-v1.4.2.tar.gz
tar -xvf libuv-v1.4.2.tar.gz
./gyp_uv.py -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.4.2
sudo ln -s /usr/lib//libuv.so.1.4.2 /usr/lib/libuv.so.1
Run ASP.NET MVC example
Clone asp.net home repository:
git clone https://github.com/aspnet/Home.git
Go to sample:
cd Home/samples/HelloMVC
Restore all required packages with:
kpm restore
Now you can run your MVC application
k kestrel
Go to http://127.0.0.1:5004 and see the result.
In next part we are gonna install PostgreSQL with NHibernate and add web api methods to our application.
Next Part: "[vNext] Use PostgreSQL + Fluent NHibernate from ASP.NET 5 (DNX) on Ubuntu"