配置Nginx
#whereis nginx
nginx: /usr/local/nginx
#如果没有nginx,网上找教程安装centos系统的nginx
#进入到程序路径,创建一个放置站点启动配置文件的文件夹
#mkdir hosts
#vi lepack.api.conf
Nginx配置站点配置文件
server {
listen 80;
server_name lepackapi.lepkg.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 $http_host;
proxy_cache_bypass $http_upgrade;
}
}
配置好之后到Nginx下面将hosts文件夹里面的conf文件加载到Nginx配置文件下面
#进入到nginx.conf下面在server配置节点下面增加
#include /usr/local/nginx/hosts/*.conf;
配置好之后重新加载nginx配置文件,动态加载
# nginx -s reload
配置netcore守护进程配置文件
# vi /etc/systemd/system/lepack-api.service #文件服务地址
[Unit]
Description=运行lepackapi服务
[Service]
WorkingDirectory=/usr/wwwroot/ #依赖环境
ExecStart=/usr/bin/dotnet /usr/wwwroot/lepack.service.api.dll --environment dev --urls http://*:5000
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=lepackapi.log
User=root
Environment=ASPNETCORE_ENVIRONMENT=dev # 环境变量
[Install]
WantedBy=multi-user.target #该服务所在的Target