标签:
Installing on Ubuntu 14.04
The following instructions were tested using Ubuntu 14.04. Other versions of Ubuntu and other Debian based distros are 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 don’t 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 is 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 You 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
安装 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
安装VS2015
安装最新发布的 asp.net 5更新补丁
创建web
发布到 ubuntu
dnu restore
dnx
示范端口:(在RC2中 Kestrel 不能仅仅是用名称Kestrel,需要是全名!!!!!!!)
"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仅仅是本机访问的绑定
*:port进行机器iP的绑定
dnx 没有对应的重启 Kestrel的命令...........
如果出现端口占用重复的问题,那么直接杀死 dnx 监听的进程即可。。。。。
lsof -i :5004
kill -9 portnumber
防火墙 打开对应的端口访问
sudo ufw allow 5004/tcp
sudo apt-get install nginx
重新启动nginx:
sudo service nginx stop
sudo service nginx start
或者
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 you can also enable gzip compression on your dynamic content. Kestrel doesn‘t have 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.NET 5 but firefly is the best in the realm of performance.
sudo apt-get install nginx
vi /etc/nginx/sites-available/default
#try_files $uri $uri/ =404;-----------一定要注释掉这个配置节点 。我们的asp.net mvc是基于路由访问控制 而不是通过CGI文件(asp php py等)
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;
接下来 就是nginx的配置了。。压缩 头信息 缓存 等等
自动启动Web
Monitoring our Web Application
Nginx will forward requests to your Kestrel server, however unlike IIS on Windows, it does not mangage your Kestrel process. In this tutorial, we will use supervisor to start our application on system boot and restart our process in the event of a failure.
Installing supervisor
sudo apt-get install supervisor
To have supervisor monitor our application, we will 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 are done 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、安装:
apt-get install ufw
2、启用:
ufw enable
ufw default deny
3、开启/禁用:
ufw allow 22/tcp 允许所有的外部IP访问本机的22/tcp (ssh)端口
ufw deny 22/tcp 禁止所有外部IP访问本机的22/tcp(ssh)端口
ufw delete deny 22/tcp 删除防火墙中的规则
有时候关闭软件后,后台进程死掉,导致端口被占用。下面以JBoss端口8083被占用为例,列出详细解决过程。
解决方法:
1.查找被占用的端口
netstat -tln
netstat -tln | grep 8083
netstat -tln 查看端口使用情况,而netstat -tln | grep 8083 则是只查看端口8083的使用情况
2.查看端口属于哪个程序?端口被哪个进程占用
lsof -i :8083
3.杀掉占用端口的进程
kill -9 进程id
Why not using ASP.NET 5 default web server, Kestrel?
Managing ASP.NET 5 web applications with Kestrel isn’t easy, or isn’t as easy as managing virtual hosts
like Apache or Nginx. Each web application must be running on one process of the Kestrel web server.
It means that we can’t run two web applications on the same port. Also, unlike Apache or Nginx, we cannot
declare our web applications in configuration files, and launch them all with a single command. We have
to run “dnx web” in a terminal for every web application! What 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 you already have 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 isn’t working for me, so I’m using the RC1.
Nginx configuration
Now let’s create a nginx configuration for our web application. We are 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 are going to add a HTTP header to be sur that it’s
Nginx that served our 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 will wait for an answer forever even if the server has sent
the response. Have a look here to find more information about this bug.
ASP.NET Core 1.0---Ubuntu 14.04
标签:
原文地址:http://www.cnblogs.com/micro-chen/p/5451540.html