centos 安裝部署.net core站點
阿新 • • 發佈:2019-02-01
entos urn etc inux 使用 runtime 切換 fire ret
安裝 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站點