ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Centos8 下部署 ASP.net Core 程序

2021-12-01 10:00:16  阅读:205  来源: 互联网

标签:Core ASP http mono repo proxy stable net com


1、安装需要的SDK包,如果程序包含3.1版本,需要安装3.1的SDK。

sudo dnf install dotnet-sdk-5.0
dotnet --version
dotnet --list-runtimes

2、net core程序中带有图片验证码需要事先安装GDI的图形库

https://www.mono-project.com/download/stable/#download-lin-centos

1、Add the Mono repository to your system

CentOS/RHEL 8 (x86_64)

rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
su -c 'curl https://download.mono-project.com/repo/centos8-stable.repo | tee /etc/yum.repos.d/mono-centos8-stable.repo'

CentOS/RHEL 7 (x86_64)

rpmkeys --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
su -c 'curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo'

CentOS/RHEL 6 (x86_64, i686)

rpm --import "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"
su -c 'curl https://download.mono-project.com/repo/centos6-stable.repo | tee /etc/yum.repos.d/mono-centos6-stable.repo'

2、Install Mono

dnf install mono-devel

使用 Nginx 在 Linux 上托管 ASP.NET Core

https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-6.0


yum install nginx -y
systemctl status nginx
systemctl enable --now nginx
systemctl start nginx
server {
    listen        80;
    server_name   example.com *.example.com;
    location / {
        proxy_pass         http://127.0.0.1:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

  

把启动命令写成服务

/etc/systemd/system/Core.service

[Unit]
Description="Core.Service"

[Service]
Type=simple
GuessMainPID=true
WorkingDirectory=/www/web/mng
StandardOutput=journal
StandardError=journal
ExecStart=/usr/lib64/dotnet/dotnet /www/web/mng/clyg_tmc_manage.dll  --urls="http://*:5000"
Restart=always
[Install]
WantedBy=multi-user.target
                         

官方给的服务配置文件,供参才考。试了多次都不能启动。

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

sudo systemctl enable kestrel-helloapp.service

sudo systemctl start kestrel-helloapp.service

sudo systemctl status kestrel-helloapp.service 

 
参考链接
https://huchengv5.github.io/post/%E5%A6%82%E4%BD%95%E5%B0%86Asp.net-Core%E7%AB%99%E7%82%B9%E9%83%A8%E7%BD%B2%E5%88%B0CentOS.html

标签:Core,ASP,http,mono,repo,proxy,stable,net,com
来源: https://www.cnblogs.com/niewd/p/15627604.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有