码迷,mamicode.com
首页 > Web开发 > 详细

ubuntu 跑.net core 2.0

时间:2017-08-04 18:19:44      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:rest   sof   linux   source   desc   文件内容   cto   mct   名称   

安装.net core参考地址:http://www.microsoft.com/net/core/preview#linuxubuntu

服务器版本     UBbuntu  16.04

 

执行命令

sudo sh -c echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main" > /etc/apt/sources.list.d/dotnetdev.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893
sudo apt-get update

 

sudo apt-get install dotnet-sdk-2.0.0-preview2-006497

安装成功。

 

然后在服务器安装nginx,参考另一篇文章   http://www.cnblogs.com/xiaoquangege/p/7285967.html

 

创建一个服务文件  在目录

/etc/systemd/system/[服务文件名称].service

文件内容

[Unit]
Description=Example .NET Web API Application running on Ubuntu

[Service]
WorkingDirectory=/var/网站目录
ExecStart=/usr/bin/dotnet /var/网站目录/hellomvc.dll
Restart=always
RestartSec=10  # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production 

[Install]
WantedBy=multi-user.target

保存文件到服务里面

systemctl enable kestrel-hellomvc.service

启动这个服务

systemctl start kestrel-hellomvc.service

 参考地址:https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction

打开网站,linux浏览.net core网站就可以啦

ubuntu 跑.net core 2.0

标签:rest   sof   linux   source   desc   文件内容   cto   mct   名称   

原文地址:http://www.cnblogs.com/xiaoquangege/p/7286326.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!