ASP. NET Core 1.0---Ubuntu 14.04

Source: Internet
Author: User

Installing on Ubuntu 14.04

The following instructions were tested using Ubuntu 14.04. Other versions of Ubuntu and other Debian based distros is unlikely to work correctly.

Install the. NET Version Manager (DNVM)
Use the. NET Version Manager (DNVM) to install different versions of the. NET execution Environment (DNX) on Linux.

Install Unzip and curl if you do not already have them:

sudo apt-get install unzip curl


Download and install DNVM:

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


Once This step was complete you should be able to run DNVM and see some help text.

Install the. NET execution Environment (DNX)
The. NET execution Environment (DNX) is used to build and run. NET projects. Use DNVM to install DNX for Mono or. NET Core (see choosing, the right. NET for your on the Server).

To install DNX for. NET Core:

Install The DNX Prerequisites:

sudo apt-get install Libunwind8 gettext libssl-dev libcurl4-openssl-dev zlib1g libicu-dev Uuid-dev


Use DNVM to install DNX for. NET Core:

DNVM Upgrade-r CORECLR

Installing LIBUV

#!/usr/bin/env Bash
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

Installing VS2015
Install the latest published ASP. NET 5 update patch
Create Web

Post to Ubuntu
DNU Restore
Dnx

Demo Port: (in RC2 Kestrel cannot just use name Kestrel, need to be full name!!!!!!! )
"Commands": {
"Web": "Microsoft.AspNet.Server.Kestrel--server.urls http://*:5004",
"Kestrel": "Microsoft.AspNet.Hosting--server Microsoft.AspNet.Server.Kestrel--server.urls http://localhost:5004",
"EF": "Entityframework.commands"
},

-----localhost is only a native access binding
*:p ort to bind the machine IP


DNX does not have a corresponding restart Kestrel command .....
If there is a duplication of port problems, then directly kill DNX monitoring process can .....
Lsof-i: 5004
Kill-9 PortNumber


Firewall to open corresponding port access

sudo ufw allow 5004/tcp

sudo apt-get install Nginx

Restart Nginx:
sudo service nginx stop
sudo service nginx start
Or
sudo nginx-s reload
sudo service nginx restart


sudo ufw allow 80/tcp

Nginx is used as a reverse proxy for static contents in general and can also enable gzip compression on your dynamic C Ontent. Kestrel doesn ' t has this feature.

Personally, I don ' t use Kestrel on Linux but Firefly which is a managed HTTP server. I also wrote a FastCGI server for ASP. 5 But Firefly are the best in the realm of performance.


sudo apt-get install Nginx

Vi/etc/nginx/sites-available/default

#try_files $uri $uri/=404;-----------Be sure to comment out this configuration node. Our ASP. NET MVC is based on routing access control rather than through CGI files (ASP php py, etc.)


Proxy_pass http://*:5004;
Proxy_http_version 1.1;
Proxy_set_header Upgrade $http _upgrade;
Proxy_set_header Connection keep-alive;
Proxy_set_header Host $host;
Proxy_cache_bypass $http _upgrade;







Next is the Nginx configuration. Compression header information Cache, etc.












Automatically start the web
Monitoring our WEB application

Nginx would forward requests to your Kestrel server, however unlike IIS on Windows, it does not mangage your Kestrel proces S. In this tutorial, we'll use supervisor to start our application on system boot and restart our process in the event O f a failure.

Installing Supervisor

sudo apt-get install Supervisor

To has supervisor monitor our application, we'll add a file to the
/etc/supervisor/conf.d/directory


[Program:bookstore]
Command=bash/home/www/test/src/bookstore/
Autostart=true
Autorestart=true
#stderr_logfile =/home/www/test/src/bookestore/hellomvc.err.log
#stdout_logfile =/home/www/test/src/bookestore/hellomvc.out.log
Environment=hosting__environment=production
User=www-data
Stopsignal=int


Once you do editing the configuration file, restart the Supervisord process to change the set of programs controlled by Supervisord.

sudo service supervisor Stop
sudo service supervisor Start



1. Installation:

Apt-get Install UFW

2. Enable:

UFW Enable

UFW default Deny

3. Turn ON/OFF:

UFW Allow 22/TCP allows all external IP access to the native 22/tcp (SSH) port

UFW deny 22/tcp Disable all external IP access to native 22/tcp (SSH) ports

UFW Delete Deny 22/tcp remove a rule from the firewall


Sometimes when the software is turned off, the background process dies, causing the port to be occupied. The following is an example of JBoss port 8083 occupancy, which lists the detailed resolution procedures.

Workaround:

1. Find the Occupied port

Netstat-tln
Netstat-tln | grep 8083
NETSTAT-TLN View port usage, while Netstat-tln | grep 8083 is a view of the usage of port 8083 only

2. See which program the port belongs to? Which process is consuming the port

Lsof-i: 8083

3. Kill the process that occupies the port

Kill-9 Process ID


Why isn't using ASP. NET 5 Default Web server, Kestrel?

Managing ASP. NET 5 Web applications with Kestrel "T easy, or isn ' t as easy as managing virtual hosts
Like Apache or Nginx. Each Web application must is running on one process of the Kestrel Web server.
It means that we can ' t run a Web applications on the same port. Also, unlike Apache or Nginx, we cannot
Declare our web applications in the configuration files, and launch them all with a single command. We have
To run ' dnx Web ' in a terminal for every web application! What's about HTTPS? Well, I ' ve saw a Nuget package
For a HTTPS Kestrel version, but it doesn ' t look like as easy to configure as the other popular Web servers.

Like I said before, I really like Nginx. Nginx is very good for serving static files and passing other
Requests to other Web servers (reverse proxying), and in our case, Kestrel.

Installation

I ' m assuming that already has a. NET environment installed on your Linux distribution. If not,
Follow the official documentation to install IT:DNVM, the. NET version manager, and the. NET Core
DNX Runtime. At this time, the RC2 of. NET Core is ' t working for me and so I ' m using the RC1.

Nginx Configuration

Now let's create a nginx configuration for our web application. We is going to proxy every request
To the Kestrel Web server except the assets such as Javascript, CSS, images and other static files.
Nginx is the best for serving static content. We is going to add a HTTP header to being sur that it ' s
Nginx that served we static content and not Kestrel.

server {
# Port and Domain
Listen 80;
server_name aspnet.local;

# Path to the Wwwroot folder
Root/home/developer/projects/webapplicationbasic/wwwroot;

# Static Content
Location ~ \. (Jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm|woff2|svg) $ {
Expires 1d;
Access_log off;
Add_header X-static-file true;
}

# Pass requests to Kestrel
Location/{
Proxy_pass http://127.0.0.1:5000;
Proxy_set_header Connection "";
Proxy_http_version 1.1;
}
}
The 19th and 20th lines are very important. It covers a bug found in the RC1 version of Kestrel.
If you don ' t add them, your browser'll wait for a answer forever even if the server has sent
The response. There is a look for here-to-find more information on this bug.

ASP. NET Core 1.0---Ubuntu 14.04

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.