asp.net 5 (vnext) Linux deployment

Source: Internet
Author: User
Tags add execution net version versions hosting oracle vm virtualbox vm virtualbox


Introduction



If you want to do something good, you must first sharpen it. First, let's first clarify the following basic concepts



Linux related


Ubuntu

Ubuntu is a free open source desktop PC operating system based on Linux that fits Intel's hyper-positioning support x86, 64-bit and PPC architecture to fully support Web browser WPS. Ubuntu is based on the Debian distribution and GNOME desktop environment, and since version 11.04, the Ubuntu release has abandoned the GNOME desktop environment to unity, unlike Debian because it publishes a new version every 6 months. The goal of Ubuntu is to provide an up-to-date and 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 a system administrator to allow ordinary users to perform some or all of the root commands, such as HALT,REBOOT,SU, and so on. This not only reduces the root user's logon and management time, but also improves security. sudo is not a substitute for the shell, it is oriented to each command.

Apt

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

Libuv

Cross-platform Asynchronous IO Library, a required component of the Kestrel server, must be installed before it is finally 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 officially renamed Oracle VM VirtualBox after Sun was acquired by Oracle. Innotek is released VirtualBox with the GNU general public License (GPL) and provides binary and OSE versions of the code. Users can install and perform 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 Web site curl.haxx.se Curl is a file transfer tool that works under the command line using URL syntax, which was first released in 1997. It supports file uploads and downloads, so it's a comprehensive transmission tool, but traditionally, it's customary to call curl a download tool. It is widely used in Unix, a variety of 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 the relevant documentation.



. NET related


Mono

Mono is a dedicated pioneer by Novell (initiated by Ximian and led by Miguel de Lcaza. NET open source projects that are 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 use C # development programs in Linux. )

Dnvm

(. NET Version Manager): For cross-platform purposes, Microsoft provides the DNVM feature, DNVM is asp.net the bottom of the content, he is a set of PowerShell script, for the Kai The specified version of the ASP.net run environment, and you can manage various versions of the ASP.net Run environment (DNX) and upgrade operations at the same point in the same machine by using the NuGet tool.

DNX

(. NET Execution Environment): DNX is the running environment for ASP.net programs to start and run asp.net programs. The running 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, which lists all the available DNX environments, while DNVM install can install the specified version of 0.1-alpha-build-0446 to the. Dnx folder, where you can Userprofile%\.dnx \runtimes directory to find all versions of DNX installed. Different operating systems have different versions of DNX.

DNU command

(DNX Utility): is a command-line package Manager, contained within the DNX, so as long as the DNX is installed, you can use the DNU command, which can be used to recover packages, install packages, deploy packages, and so on, For example, the custom assembly in the Project.json is automatically downloaded and used.

DNX command

Dnx.exe is a command-line tool for starting a hosted environment (Self-hosting), and when you start a program from a hosting environment using command-line code, DNX is responsible for locating and invoking the CLR Native HOST,DNX command is the entry point for the entire running environment, and you can use DNX Run to start the program.

Kestrel

ASP.net 51 Web server implementations based on LIBUV components.

NuGet

NuGet is an open source project under the. NET platform, which is an extension of Visual Studio. When using Visual Studio to develop applications based on the. NET framework, NuGet can quickly and easily add, remove, and update references to projects




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



Interpretation of ASP.net 5 & MVC6 Series (4): core technology and environmental configuration



Install Ubuntu



Let's take the current more popular Ubuntu 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 humane, here without a statement.



After the installation completes and enters the system, slightly cleans down the left side the shortcut, drags out the commonly used terminal command, we go to the following interface, prepares to enter the next installment.






Install Mono



The following command line may have a long download time to install mono–.



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 for mono installation complete:






If the installation is not completed successfully, refer to the Mono Project site for the latest installation method.



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



Install DNVM



First you need to install the Curl program



sudo apt-get Install Curl



Then use Curl to install 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 add the-f parameter to force overwrite updates.



Finally, run the following command to confirm that the currently installed operating environment



DNVM List






Since the DNX version of the current VS2015 RC is 1.0.0-beta4, please make sure that the active version is 1.0.0-beta4. (I am more miscellaneous here, in fact, no 11855 of those 2 are also possible)



In addition, you can find that the DNX and Dnu 2 commands (you can run these 2 commands on the console and see Help information) have been deployed to complete the DNVM installation.



Configuring ASP.net code



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






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



Unzip any directory in the virtual machine.



In addition, we do not have the Windows environment can use visual Studio code for editing, the tool is very easy to install, the specific installation method can refer to 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:



Let's make some adjustments to the project file:






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



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



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



Of course, these adjustments can also be adjusted in Windows first, and then copy 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, use the DNU command to perform recovery operations for all related components:



DNU Restore



Note that this is often interrupted by network problems, and repeated execution of this command is possible. (Do not easily break this command, will cause bad packets), until a large number of installing information and complete the Project.lock.json file, the recovery process is completed smoothly, the following figure:






Then run the following command to execute this asp.net 5 program.



Dnx. Kestrel



However, this may still be the error, because the general newly installed system does not have LIBUV components. Ultimately, 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



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






Use browsers to access http:// virtual machines ip:5000/project_readme.html or http:// virtual machines ip:5000/api/ Values can see the page and default Webapi return content. If you are interested, you can also add other pages to the wwwroot or add other Webapi to the controller-even add controller, View, and model files to show the content of MVC.



Conclusion



Of course, the program we're running today is just a very simple version, not including EF, SIGNALR, identity and other complex components, but from the entire deployment process, we can feel that the gap is actually very small. Running and deploying the environment DNVM and Dnu First, the DNX command and VS 2015 environments are consistent, and component packages are obtained from NuGet, which is not much different from the standard Windows development environment, so it can be foreseen that even the more complex asp.net 5 applications Can still be fully deployed to the Linux environment, coupled with future EF technology for MSSQL and other Cross-platform databases, better support. NET developers can launch their own linux–kestrel/jexus–mysql–asp.net cross-platform scenarios in the future.




Related Article

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.