ASP. NET 5 (VNext) Linux deployment

Source: Internet
Author: User
Tags asp net hosting oracle vm virtualbox vm virtualbox

Original: ASP. NET 5 (VNext) Linux deployment

Introduction

工欲善其事, its prerequisite. First, let's start by defining the following basic concepts

Linux related

Ubuntu

Ubuntu is a Linux-based free open-source desktop PC operating system that fits perfectly with Intel's ultra-polar positioning support for the x86, 64-bit, and PPC architectures to fully support the Web browser WPS. Ubuntu is based on the Debian distribution and GNOME desktop environment, and from version 11.04, the Ubuntu release has abandoned the GNOME desktop environment to unity, unlike Debian, which releases a new version every 6 months. The goal of Ubuntu is to provide an up-to-date, yet fairly stable, operating system built primarily of free software for the average user.

Sudo

sudo is a Linux system Management Directive, a tool that allows the system administrator to let ordinary users perform some or all of the root commands, such as HALT,REBOOT,SU, and so on. This not only reduces the login and administration time of the root user, but also improves security. sudo is not a substitute for the shell, it is for each command.

Apt

The Advanced Packaging Tool (APT) is an installation package management tool under Linux. APT consists of several programs that begin with the name "apt-". Apt-get, Apt-cache, and Apt-cdrom are command-line tools for handling software packages.

Libuv

The cross-platform asynchronous IO Library, which is a required component of Kestrel Server, must be installed before the final run.

VirtualBox

VirtualBox is an open-source virtual machine software. VirtualBox was developed by the German Innotek company, software produced by Sun Microsystems, which was written using QT, and was formally renamed Oracle VM VirtualBox after Sun was acquired by Oracle. Innotek releases VirtualBox in the GNU general public License (GPL) and provides a binary version and an OSE version of the code. Users can install and execute Solaris, Windows, DOS, Linux, Os/2 Warp, BSD and other systems as client operating systems on VirtualBox

Curl

CURL Curl-o Output Results Original author Daniel Stenberg initial version 1997 stable version 7.40.0 (January 8, 2015, 27 days ago) Development status Active
Programming language C Operating system cross-platform type Ftp/http license Agreement free software: mit/x derivate License website curl.haxx.se Curl is a file transfer tool that works under the command line using URL syntax, first released in 1997. It supports file uploads and downloads, so it is a comprehensive transfer tool, but traditionally, it is customary to call curl as a download tool. It is widely used in Unix, multiple Linux distributions, and has a ported version of DOS and Win32, Win64

Linux related knowledge is not the main content of this article, other information please refer to related documents.

. NET related

Mono

Mono is a company created by Novell (initiated by Ximian and led by Miguel de Lcaza, a dedicated pioneer. NET open source project used on Linux. It contains a C # language compiler, a CLR runtime, and a set of class libraries, and implements both ADO Net and ASP NET. Enables developers to develop programs in Linux with C #. )

Dnvm

(. NET Version Manager): Microsoft provides DNVM capabilities for cross-platform purposes, DNVM is the bottom-level content of ASP., a set of PowerShell scripts that launches the specified version of the ASP. NET runtime environment, and can manage various versions of the ASP. NET runtime Environment (DNX) at the same point on the same machine, and perform appropriate upgrade operations.

DNX

(. NET execution Environment): DNX is the operating environment of the ASP, which is used to start and run the ASP. The runtime environment includes the compilation system, the SDK toolset, and the Native CLR hosting environment. You can use DNVM to manage various versions of DNX, such as the DNVM List command to list all available DNX environments, while DNVM install 0.1-alpha-build-0446 installs the specified version of Dnx to the. Dnx folder, which you can Find all versions of DNX installed under the Userprofile%\.dnx\runtimes directory. Different operating systems have different versions of DNX.

DNU command

(DNX Utility): is a command-line package Manager, included in the DNX, so as long as DNX is installed, you can use the DNU command, which can be used to recover packages, install packages, deploy packages, etc. For example, the custom assemblies in Project.json are downloaded automatically for use.

DNX command

Dnx.exe is a command-line tool for starting a self-hosted environment (self-hosting), and DNX is responsible for locating and invoking the CLR Native host,dnx command, which is the entry point for the entire runtime, when using command-line code to launch a self-hosted environment, you can use the DNX Run to start the program.

Kestrel

ASP. 51 Web server implementations based on the LIBUV component.

NuGet

NuGet is an open source project under the. NET platform, which is an extension of Visual Studio. When you use Visual Studio to develop. NET framework-based apps, NuGet makes it faster and easier to add, remove, and update references in your project

about ASP . Core Technology, please refer to Uncle Tom's blog for further information:

Interpreting ASP 5 & MVC6 Series (4): Core technology and environment configuration

Install Ubuntu

We take the current popular Ubuntu as an example, my configuration environment is:

L Host: Win8.1 and VS2015 RC

L Virtual machine: Virtualbox-4.3.28-100309-win

L LINUX:UBUNTU-15.04-DESKTOP-AMD64

The installation process of these software is more humanized, here is not added.

After the installation is complete and entered the system, slightly clean down the left side of the shortcut, drag out the common terminal commands, we go to the following interface, ready to go to the next installation.

Installing mono

The installation mono– download time can be very long with the following command line.

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

echo "Deb Http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee-a/etc/apt/sources.list.d/mono-xamarin.list

sudo apt-get update

sudo apt-get install Mono-devel

It is recommended that you run the problematic command again if there is a problem. See the following results to indicate that mono installation is complete:

If the installation does not complete successfully, refer to the Mono Project website for the latest installation methods.

http://www.mono-project.com/docs/getting-started/install/linux/

Installing DNVM

First you need to install the Curl program

sudo apt-get Install Curl

Then use Curl to install the DNVM

Curl-ssl https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | Dnx_branch=dev sh && Source ~/.dnx/dnvm/dnvm.sh

After installation, use the DNVM Upgrade command to get the latest operating environment

DNVM Upgrade

If you encounter an update failure, you can join the-f parameter to forcibly overwrite the update.

Finally, run the following command to confirm the current installation of the running environment

DNVM List

Since the DNX version of VS2015 RC is currently 1.0.0-BETA4, please ensure that the current active version is 1.0.0-beta4. (I am here to install the miscellaneous, in fact, no 11855 of those 2 is also possible)

You can also find the DNX and Dnu 2 commands (you can run these 2 commands in the console, see the Help information) have been deployed, to this DNVM installation is complete.

Configuring ASP.

In the window host, use vs 2015 to build a vnext version of the WEBAPI program.

This project is named WebApi2015. After the setup is complete, the program directory is packaged and delivered to the Ubuntu virtual machine.

Unzip any directory on the virtual machine.

In addition, our non-Windows environment can be edited with visual Studio code, which is very easy to install and can be installed in the official website:

Https://code.visualstudio.com/Docs/setup

Although this tool is not as convenient as VS, it is a lot more advanced than a text editor:

Here we make some adjustments to the project files:

L Add a reference to the Kestrel component, which is a required web Server in the Linux environment.

L Add Kestrel command line, set the start URL to http://localhost:5000, this step is necessary, otherwise the subsequent DNX command will not be executed.

L move project_readme.html into wwwroot as a static page that can be displayed.

Of course, these adjustments can be adjusted in Windows first, and then copied over.

Deploy and run

Open a terminal and set the current path to the src/webapi2015 in our project, which is the directory where Project.json is located.

First, the DNU command is used to restore all related components:

DNU Restore

Note that this is often interrupted by network problems and repeated execution of this command. (Do not forcibly interrupt this command, will cause bad packets), until a large number of installing information and complete the Project.lock.json file, the recovery process is not a smooth end, such as:

Then run the following command to execute this ASP. NET 5 program.

Dnx. Kestrel

this time, however, the error may still be due to the fact that the newly installed system does not yet have a LIBUV component. Finally, we also need to use the following command to install the LIBUV component.

sudo apt-get install Automake libtool

Curl-ssl https://github.com/libuv/libuv/archive/v1.4.2.tar.gz | sudo tar zxfv--c/usr/local/src

cd/usr/local/src/libuv-1.4.2

sudo sh autogen.sh

sudo./configure

sudo make

sudo make install

sudo rm-rf/usr/local/src/libuv-1.4.2 && cd ~/

sudo ldconfig

Once the installation is complete, run dnx. Kestrel and run through

Use browser to access HTTP .// virtual machine ip:5000/project_readme.html or http // virtual machine ip:5000/api/values You can see the page and the default Webapi return content. If you're interested, you can also try adding other pages to the wwwroot or adding other Webapi to the controller-even adding controllers, View, and model files to show the MVC content.

Conclusion

Of course, the current program we are running is only a very simple version, not including the EF, SignalR, identity and other complex components, but from the entire deployment process, we can feel that the gap is very small. First run and deploy the environment DNVM and DNU, the DNX command is consistent with the VS 2015 environment, and the component packages are obtained from NuGet, which is not so different from the standard Windows development environment, so it is foreseeable that even more complex ASP. NET 5 Applications Can still be fully deployed to the Linux environment, plus the future EF technology to the MSSQL and other cross-platform database support better. NET developers can launch their own linux–kestrel/jexus–mysql–asp.net cross-platform scenarios in the future.

ASP. NET 5 (VNext) Linux deployment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.