一佳一

记录像1+1一样简洁的代码

导航

麒麟V10 .NET6 部署教程

Posted on 2024-08-05 12:56  一佳一  阅读(149)  评论(0编辑  收藏  举报

1. .NETCORE 环境 这里我用的是.NET6

rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
yum install dotnet-sdk-6.0

 2. 上传文件然后解压FTP,我这里用rar所以要装一下

yum install unrar

unrar x 你的项目.rar

3.安装和配置nginx

yum install nginx

#nginx开机启动
sudo systemctl start nginx
sudo systemctl enable nginx

#nginx启动测试
sudo service nginx start

#测试一下
curl http://127.0.0.1

4.进程守护,麒麟的比较麻烦,要耐心看步骤

  1. 输入命令:yum install python-setuptools
  2. 输入命令:easy_install supervisor
  3. 配置Supervisor:mkdir /etc/supervisor  执行  echo_supervisord_conf > /etc/supervisor/supervisord.conf 生成配置
  4. 修改配置文件:
    [include]
    files = relative/directory/*.ini
  5. 在/etc/supervisor/下创建conf.d文件夹,并放入配置文件
  6. [program:project]
    command=dotnet project.dll
    directory=/usr/project
    environment=ASPNETCORE__ENVIRONMENT=Production
    user=root
    stopsignal=INT
    autostart=true
    autorestart=true
    startsecs=1
    stderr_logfile=/var/log/project.err.log
    stdout_logfile=/var/log/project.out.log

     

  7. 设置开机启动,需先创建开机服务

    再配置前,先关闭supervisor

    ps -ef | grep super

    查找进程,再杀掉

    kill -9  进程号

    新建系统服务文件

    vi  /usr/lib/systemd/system/supervisor.service

    输入下面内容

    [Unit]
    Description=supervisor
    After=network.target
    ​
    [Service]
    Type=forking
    ExecStart=/usr/bin/supervisord -c /etc/supervisor/supervisord.conf
    ExecStop=/usr/bin/supervisorctl $OPTIONS shutdown
    ExecReload=/usr/bin/supervisorctl $OPTIONS reload
    KillMode=process
    Restart=on-failure
    RestartSec=42s
    ​
    [Install]
    WantedBy=multi-user.target
     
  8. 然后设置开机启动的内容

    systemctl daemon-reload
    systemctl start supervisor.service
    systemctl status supervisor.service

    最后设置成自启动

    systemctl enable supervisor.service