1-进入 配置文件夹
cd /etc/nginx/cof.d
2-创建一个一站点名称命名的配置文件
vim kestrel-syslyracom.conf
3-在.conf 文件中输入以下代码,只需要改动端口号,然后退出保存
server {
listen 8001;
server_name www.xxxx.com;
location / {
proxy_pass http://localhost:5001;
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;
}
}
4.验证配置,重新载入
sudo nginx -t
sudo nginx -s reload
5.如果报错 nginx: [error] invalid PID number "" in "/run/nginx.pid" 执行以下命令
nginx -c /etc/nginx/nginx.conf
nginx.conf文件的路径可以从nginx -t的返回中找到。
nginx -s reload
6-创建服务守护 dotnetcore 的程序进程
cd /etc/systemd/system
vim kestrel-syslyracom.service
7.在.service文件中贴入以下代码 ,退出保存
[Unit]
Description=syscnlyracom
[Service]
WorkingDirectory=/var/www/syscnlyracom
ExecStart=/usr/bin/dotnet /var/www/sys.cnlyra.com/Site.WebApi.dll
Restart=always
RestartSec=10
SyslogIdentifier=syscnlyracom
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
8-重启服务
systemctl restart kestrel-syslyracom.service