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

centos 安装部署.net core站点

时间:2019-02-01 20:17:06      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:netcore   dir   lse   load   user   com   mic   log   url   

安装 net core

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
sudo yum update -y

#sdk runtime二选一
sudo yum install dotnet-sdk-2.2
sudo yum install aspnetcore-runtime-2.2

dotnet --version #sdk
dotnet --info #runtime

#runtime使用
dotnet xx.dll

#sdk切换到代码目录使用
dotnet run

指定ip端口

public static IWebHost BuildWebHost(string[] args)
{
    return WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://*:80;")
            .UseStartup<Startup>()
            .Build();
}

服务守护

sudo nano /etc/systemd/system/kestrel-helloapp.service


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

[Service]
WorkingDirectory=/var/www/helloapp
ExecStart=/usr/bin/dotnet /var/www/helloapp/helloapp.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
systemctl enable kestrel-helloapp.service
systemctl start kestrel-helloapp.service
systemctl status kestrel-helloapp.service

前后台切换

ctrl+z 后台暂停
bg 添加到后台继续运行
fg 回到前台

配置防火墙端口

firewall-cmd --permanent --zone=public --add-port=8083/tcp
firewall-cmd --permanent --zone=public --add-port=1433/tcp
firewall-cmd --reload

参考:
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2

centos 安装部署.net core站点

标签:netcore   dir   lse   load   user   com   mic   log   url   

原文地址:https://www.cnblogs.com/wswind/p/10346871.html

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