centos7 开机自启dotnetcore3.1项目
1.上传文件
假设AspNet Core项目名为xxx
,开发完成后发布到文件夹,然后把整个PublishOutput
文件夹的文件复制到Centos7的目录/var/aspnetcore/xxx
。修改目录的owner,因为后面使用nginx用户自启动,所以owner修改为nginx:
chown -R nginx:nginx /var/aspnetcore/xxx
2. 创建自启动文件
vi /etc/systemd/system/dotnetcore.service
[Unit]
Description=xxx program on centos7
[Service]
WorkingDirectory=/home/zhuyongchao/dotnet/11/vs2019core-test.dll
ExecStart=/usr/bin/dotnet /home/zhuyongchao/dotnet/11/vs2019core-test.dll
Restart=always
RestartSec=10 # Restart service after 10 seconds if dotnet service crashes
SyslogIdentifier=dotnet-xxx
[Install]
WantedBy=multi-user.target
3. 使自启动生效
systemctl enable xxx.service
4. 立即启动服务
systemctl start xxx.service
5. 查看服务状态
systemctl status xxx.service
- redmine 81
- vuepress博客 8081
- Gitlab 8088
- vue 8800 8900
- dotnetcore 5000/swagger/