鼎鼎知识库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

.NETCore在Ubuntu18.04下开机自启动.md 798B

1234567891011121314151617181920212223242526
  1. - 来到根目录:cd /
  2. - 创建文件:sudo touch /etc/systemd/system/znzm.service
  3. - 来到目录:/etc/systemd/system
  4. - 修改文件的权限:sudo chmod 666 znzm.service
  5. ```
  6. [Unit]
  7. Description=znzm running on Ubuntu
  8. [Service]
  9. WorkingDirectory=/var/www/znzm
  10. ExecStart=/usr/bin/dotnet /var/www/znzm/DD.Local.Web.dll
  11. Restart=always
  12. # Restart service after 10 seconds if the dotnet service crashes:
  13. RestartSec=10
  14. SyslogIdentifier=dotnet-example
  15. User=www-data
  16. Environment=ASPNETCORE_ENVIRONMENT=Production
  17. [Install]
  18. WantedBy=multi-user.target
  19. ```
  20. - 修改文件的执行权限:sudo chmod +x znzm.service
  21. - 启用服务:sudo systemctl enable znzm.service
  22. - 启动服务:sudo systemctl start znzm.service
  23. - 查看服务:sudo systemclt status znzm.service
  24. - 重启服务器:sudo reboot