netcore linux环境部署和守护进程

分类: NetCore

配置Nginx

  1. #whereis nginx
  2. nginx: /usr/local/nginx
  3. #如果没有nginx,网上找教程安装centos系统的nginx
  4. #进入到程序路径,创建一个放置站点启动配置文件的文件夹
  5. #mkdir hosts
  6. #vi lepack.api.conf

Nginx配置站点配置文件

  1. server {
  2. listen 80;
  3. server_name lepackapi.lepkg.com;
  4. location / {
  5. proxy_pass http://127.0.0.1:5000;
  6. proxy_http_version 1.1;
  7. proxy_set_header Upgrade $http_upgrade;
  8. proxy_set_header Connection keep-alive;
  9. proxy_set_header Host $http_host;
  10. proxy_cache_bypass $http_upgrade;
  11. }
  12. }

配置好之后到Nginx下面将hosts文件夹里面的conf文件加载到Nginx配置文件下面

  1. #进入到nginx.conf下面在server配置节点下面增加
  2. #include /usr/local/nginx/hosts/*.conf;

配置好之后重新加载nginx配置文件,动态加载

  1. # nginx -s reload

配置netcore守护进程配置文件

  1. # vi /etc/systemd/system/lepack-api.service #文件服务地址
  2. [Unit]
  3. Description=运行lepackapi服务
  4. [Service]
  5. WorkingDirectory=/usr/wwwroot/ #依赖环境
  6. ExecStart=/usr/bin/dotnet /usr/wwwroot/lepack.service.api.dll --environment dev --urls http://*:5000
  7. Restart=always
  8. RestartSec=10
  9. KillSignal=SIGINT
  10. SyslogIdentifier=lepackapi.log
  11. User=root
  12. Environment=ASPNETCORE_ENVIRONMENT=dev # 环境变量
  13. [Install]
  14. WantedBy=multi-user.target #该服务所在的Target
  • 启动和配置守护进程

    1. # systemctl enable lepack.api.service
    2. # systemctl start lepack.api.service
    3. # systemctl stop lepack.api.service
标签: NetCore

上一篇: jenkins构建配置(NetCore)

下一篇: codefirst和databasefirst操作

by 2023-08-07 23:49:08
篇笔记

学习笔记