You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

run-as-service-in-ubuntu.en-us.md 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ---
  2. date: "2017-07-21T12:00:00+02:00"
  3. title: "Run as service in Linux"
  4. slug: "linux-service"
  5. weight: 10
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "installation"
  11. name: "Linux service"
  12. weight: 20
  13. identifier: "linux-service"
  14. ---
  15. ### Run Gitea as Linux service
  16. You can run Gitea as service, using either systemd or supervisor. The steps below tested on Ubuntu 16.04, but those should work on any Linux distributions (with little modification).
  17. #### Using systemd
  18. Copy the sample [gitea.service](https://github.com/go-gitea/gitea/blob/master/contrib/systemd/gitea.service) to `/etc/systemd/system/gitea.service`, then edit the file with your favorite editor.
  19. Uncomment any service that needs to be enabled on this host, such as MySQL.
  20. Change the user, home directory, and other required startup values. Change the
  21. PORT or remove the -p flag if default port is used.
  22. Enable and start Gitea at boot:
  23. ```
  24. sudo systemctl enable gitea
  25. sudo systemctl start gitea
  26. ```
  27. If you have systemd version 220 or later, you can enable and immediately start Gitea at once by:
  28. ```
  29. sudo systemctl enable gitea --now
  30. ```
  31. #### Using supervisor
  32. Install supervisor by running below command in terminal:
  33. ```
  34. sudo apt install supervisor
  35. ```
  36. Create a log dir for the supervisor logs:
  37. ```
  38. # assuming Gitea is installed in /home/git/gitea/
  39. mkdir /home/git/gitea/log/supervisor
  40. ```
  41. Append the configuration from the sample
  42. [supervisord config](https://github.com/go-gitea/gitea/blob/master/contrib/supervisor/gitea) to `/etc/supervisor/supervisord.conf`.
  43. Using your favorite editor, change the user (git) and home
  44. (/home/git) settings to match the deployment environment. Change the PORT
  45. or remove the -p flag if default port is used.
  46. Lastly enable and start supervisor at boot:
  47. ```
  48. sudo systemctl enable supervisor
  49. sudo systemctl start supervisor
  50. ```
  51. If you have systemd version 220 or later, you can enable and immediately start supervisor by:
  52. ```
  53. sudo systemctl enable supervisor --now
  54. ```