The latest ASP. NET vNext is fully open-source and can run across multiple platforms. in Windows, I tried to run the Sample without any effort, in the Linux environment, it takes a lot of time, so it is particularly important to record the entire process and hope to help others who want to taste it.
Running Environment
Ubuntu Server 14.04
VirtualBox
Mono> = 3.4.1
* Because the Mono version in the Ubuntu library is outdated and does not meet the minimum requirements, the first step is to install the latest Mono version.
Install Mono
1. first obtain the mono code from GitHub:git clone git://github.com/mono/mono.git
* If you have not installed the git program, you must first execute it In Ubuntu.sudo apt-get install git
Command.
2. This step is a bit strange. Compiling the new version of mono requires the support of the old version. If mono is not installed, run it in Ubuntu first.sudo apt-get install mono-complete
Command.
3. Go to the mono directory and compile the program:
cd mono./autogen.sh --prefix=/usr/localmake
* Other programs, such as autoconf, libtool, g ++, and make, may need to be installed in advance.
4. installation:make install
5. Executemozroots --import --sync
Command to avoid authentication problems.
6. Passmono –version
Command to confirm that the installed mono is the latest version.
Install KRE
You only need a simple command:
curl https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh && kvm upgrade
kvm upgrade
The command automatically downloads the latest KRE package, decompress it to The. kre/packages directory, and add the bin folder PATH to your environment variable PATH.
* Unzip must be installed in advance because decompression is involved:sudo apt-get install unzip
After installation, you can usekpm –version
Command to check whether the installation is correct.
Hello World
After all preparations are completed, you can try to run the first program. Traditionally, the first program should be "Hello World !"
1. First create the HelloWorld Folder:mkdir HelloWorld
2. After Entering the folder:cd HelloWorld
Create two files, Program. cs and project. json.
3. edit these two files (vim is recommended) and add the following code to Program. cs:
using System;public class Program{ public static void Main() { Console.WriteLine("Hello World!"); }}
Add the following configuration to the project. json file:
{ "dependencies": { "System.Console": "4.0.0.0" }, "configurations": { "net45": {}, "k10": {} }}
4. Executekpm restore -s https://www.myget.org/F/aspnetvnext/
Command.
* This command retrieves necessary Dependencies from the specified nuget repository according to the description in the configuration file.
5. Run the program:k run
If the above steps are correct, you should be able to see "Hello World!" in shell !" .
Simple MVC
Next, try a complicated program, and the code can be obtained directly from GitHub.
git clone git://github.com/aspnet/Home.git
The HelloMvc Code cannot be used directly because the specified Web server does not exist in Linux. We also need to add a project to generate a Web server.
Slave.
Then modify the project. json file of HelloMvc:
{ "version": "0.1-alpha-*", "dependencies": { "Microsoft.AspNet.Mvc": "0.1-alpha-*", "Nowin.vNext": "" }, "commands": { "web": "Microsoft.AspNet.Hosting --server Nowin.vNext" }, "configurations": { "net45": { "dependencies": { "System.Runtime": "", "System.ComponentModel.DataAnnotations": "" } }, "k10": {} }}
Run in this waykpm restore
After downloading the dependency, runk web
Command to view the web page in the browser.
* In fact, there will still be errors during the above execution. You needapp.UseErrorPage();
Andapp.UseWelcomePage();
Comment out the statement. The assumption is that the Nowin. vNext server is not implemented.
Client Access
Because the Ubuntu Server used in this experiment has not installed the desktop environment, you cannot view the above results in the virtual machine. However, since the virtual machine has become a server, consider the host machine as a client.
In the network settings of VirtualBox, change the connection mode to a bridge Nic, so that the host can access the virtual machine through an IP address.
The Web server port number in the previous example is 8080. Therefore, enter "Virtual Machine IP Address: 8080" in the browser of the host machine and press enter to see the final result.