Linux Hosting ASP

Linux Hosting ASP

Most of us are aware of Linux hosting, because Linux is a most popular, cheap, reliable and secure platform, and with this, ASP.NET technology is most used technology. In this article, we will see how this popular platform and this most used technology combines, in the form of Installing ASP.NET 5 On Linux.

How to Install ASP.NET 5 On Linux
To install ASP.NET 5 on Linux, several methods are available; we have covered some of them.

Install ASP.NET 5 On Linux using prebuild binaries
ASP.NET 5 can be installed on Linux via Prebuild binaries in an appropriate way based on users system configuration. With this, one more method is available; User can use the .NET Version Manager (DNVM) to install the same.
Remember, for both the methods of installation, User is required to install the prerequisites for their particular distribution, explained in the coming sections.

Install ASP.NET 5 on Ubuntu 14.04
When using Ubuntu 14.04, given instructions were tested.
.NET Version Manager (DNVM) must be used by the user for installing various versions of the .NET Execution Environment (DNX) on Linux.
User needs to install the unzip and curl the same if he don’t have that.
sudo apt-get install unzip curl
For this, user must download the DNVM and then install the same
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
After completion of the above step, user can run DNVM.
Install the .NET Execution Environment (DNX)
To build and run .NET projects, .NET Execution Environment (DNX) is used. For installing DNX for Mono or .NET Core, used the DNVM.
In order to install DNX for .NET Core, first user must needs to install the DNX prerequisites
sudo apt-get install libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev uuid-dev
With the help of DNVM, DNX is installed for .NET Core:
dnvm upgrade -r coreclr
In order to install the DNX for Mono, Mono must be installed, for this user can use the mono-complete package. User must make sure that ca-certificates-mono package must be installed in the same way as they are given in the instructions on how to install Mono.
DNVM for installing DNX for Mono
dnvm upgrade -r mono
DNX for Mono is installed by default by DNVM if no runtime is mentioned.
Installation of Libuv
Libuv is an asynchronous Input-Output library, using more than one platform, used by Kestrel. Kestrel, using cross-platform, is an HTTP server host ASP.NET 5 web applications.
For building libuv, perform the following:
sudo apt-get install make automake libtool curl
curl -sSL https://github.com/libuv/libuv/archive/v1.8.0.tar.gz | sudo tar zxfv – -C /usr/local/src
cd /usr/local/src/libuv-1.8.0
sudo sh autogen.sh
sudo ./configure
sudo make
sudo make install
sudo rm -rf /usr/local/src/libuv-1.8.0 && cd ~/
sudo ldconfig

Install ASP.NET 5 on CentOS 7
Given instructions were tested when CentOS 7 is used. It is possible, other versions may not work correctly.
First, Install the .NET Version Manager (DNVM)
.NET Version Manager (DNVM) is used for installing various versions of the .NET Execution Environment (DNX) on Linux.
User must first install unzip, if it is not there.
sudo yum install unzip
Now follow the given link to download and install the DNVM
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
After this, User can run DNVM.
Installation of .NET Execution Environment (DNX)
For build and run .NET projects, .NET Execution Environment (DNX) is used. DNVM is used for installing DNX for Mono.
Installing the DNX for Mono
First, install Mono using mono-complete package. Make sure that ca-certificates-mono package is installed as instructions given in the Mono installation process.
For installing DNX for Mono, Use DNVM
dnvm upgrade -r mono
When runtime is not mentioned, by default DNX for Mono is installed by DNVM.
Install Libuv
Same as given above

Install ASP.NET 5 on Linux Using Docker
Here given instructions were tested with Ubuntu 14.04 and Docker 1.8.3.
First of all, User must Install Docker, then create a Dockerfile inside an application folder, as given below,
# Base of your container
FROM microsoft/aspnet:latest

User has the choice between Mono and CoreCLR. Microsoft Docker Hub can also be used by the user to pick a different base which is running either on CoreCLR or its older version.
Now, after having an application, follow the given commands to use and run the container
docker build -t yourapplication
docker run -t -d -p 8080:5000 yourapplication
These are the several ways by which ASP.NET 5 can be installed on Linux.