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 請求分發
待續....
版權聲明
作者:扶我起來我還要敲
地址:http://www.rzrgm.cn/Newd/p/8595497.html
? Newd 尊重知識產權,引用請注出處
廣告位
(虛位以待,如有需要請私信)
浙公網安備 33010602011771號