linux centos7 和 windows下 部署 .net core 2.0 web应用

centos7 下部署asp.net core 2.0应用

  • 安装CentOS7
  • 配置网络【可选】
  • 安装.Net core2.0
  • 创建测试Asp.net Core应用程序 
  • 正式部署项目

安装VMware->新建虚拟机->找到系统镜像->一步一步往下装,不多说了。。

如果ping baidu.com ping不通, 系统版本可能没有配置网络

博客园有很多CentOs配置网络的文章自己去搜索一下。。

安装.Net core2.0,创建测试Asp.net Core应用程序:

按照官网来就行,不再赘述:

https://www.microsoft.com/net/learn/get-started/linux/rhel#install

正式部署项目:

查看主机IP

使用FTP上传程序包到Linux

打开终端->找到项目根目录->执行 dotnet xxx.web.dll ,这个xxx.web.dll是指你的web应用程序集。

搞定!

使用:IP+端口访问去吧。

部署之Docker

待续....

Windows下部署asp.net core 2.0 之  Kestrel

如果没有运行环境,请去下载: https://www.microsoft.com/net/learn/get-started/windows

打开cmd,使用cd /d c:\xxxpatn 命令 找到发布的项目根目录;运行dotnet xxx.web.dll,这个xxx.web.dll是指你的web应用程序集。

没有问题的话看下面

 

本地访问:http://localhost:5000

使用Nginx反向代理服务器映射端口到80:

下载:http://nginx.org/en/download.html  安装

配置  \conf\nginx.conf 文件

  1 #user  nobody;
  2 worker_processes  1;
  3 
  4 #error_log  logs/error.log;
  5 #error_log  logs/error.log  notice;
  6 #error_log  logs/error.log  info;
  7 
  8 #pid        logs/nginx.pid;
  9 
 10 
 11 events {
 12     worker_connections  1024;
 13 }
 14 
 15 
 16 http {
 17     include       mime.types;
 18     default_type  application/octet-stream;
 19 
 20     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 21     #                  '$status $body_bytes_sent "$http_referer" '
 22     #                  '"$http_user_agent" "$http_x_forwarded_for"';
 23 
 24     #access_log  logs/access.log  main;
 25 
 26     sendfile        on;
 27     #tcp_nopush     on;
 28 
 29     #keepalive_timeout  0;
 30     keepalive_timeout  65;
 31 
 32     #gzip  on;
 33     #配置服务器地址,可以有多台,localhost 为 服务名
 34     upstream localhost {
 35      server 127.0.0.1:5000 weight=1;
 36     }
 37     
 38     server {
       #侦听80端口
39 listen 80;
       #服务名称必须和upstream后面的名称一致
40 server_name localhost; 41 42 #charset koi8-r; 43 44 #access_log logs/host.access.log main; 45 46 #location / { 47 # root html; 48 # index index.html index.htm; 49 #} 50 #指定访问时转发到哪里,localhost为服务名 51 location / { 52 proxy_pass http://localhost; 53 } 54 55 #error_page 404 /404.html; 56 57 # redirect server error pages to the static page /50x.html 58 # 59 error_page 500 502 503 504 /50x.html; 60 location = /50x.html { 61 root html; 62 } 63 64 # proxy the PHP scripts to Apache listening on 127.0.0.1:80 65 # 66 #location ~ \.php$ { 67 # proxy_pass http://127.0.0.1; 68 #} 69 70 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 71 # 72 #location ~ \.php$ { 73 # root html; 74 # fastcgi_pass 127.0.0.1:9000; 75 # fastcgi_index index.php; 76 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 77 # include fastcgi_params; 78 #} 79 80 # deny access to .htaccess files, if Apache's document root 81 # concurs with nginx's one 82 # 83 #location ~ /\.ht { 84 # deny all; 85 #} 86 } 87 88 89 # another virtual host using mix of IP-, name-, and port-based configuration 90 # 91 #server { 92 # listen 8000; 93 # listen somename:8080; 94 # server_name somename alias another.alias; 95 96 # location / { 97 # root html; 98 # index index.html index.htm; 99 # } 100 #} 101 102 103 # HTTPS server 104 # 105 #server { 106 # listen 443 ssl; 107 # server_name localhost; 108 109 # ssl_certificate cert.pem; 110 # ssl_certificate_key cert.key; 111 112 # ssl_session_cache shared:SSL:1m; 113 # ssl_session_timeout 5m; 114 115 # ssl_ciphers HIGH:!aNULL:!MD5; 116 # ssl_prefer_server_ciphers on; 117 118 # location / { 119 # root html; 120 # index index.html index.htm; 121 # } 122 #} 123 124 }

 

配置好之后:我们cmd->cd /d Nginx目录->start nginx 

访问 http://localhost 搞定!

Nginx其他命令:nginx -s stop 停止

 

Windows下部署asp.net core 2.0 之  IIS

待续....

Nginx 请求分发

待续....

转载于:https://www.cnblogs.com/Newd/p/8595497.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值