Files
docs/versioned_docs/version-1.22/installation/run-as-service-in-ubuntu.md
T

70 lines
1.8 KiB
Markdown
Raw Normal View History

2017-11-26 16:44:32 -05:00
---
date: "2017-07-21T12:00:00+02:00"
2024-08-06 16:44:42 -07:00
2017-11-26 16:44:32 -05:00
slug: "linux-service"
2023-07-25 23:53:13 -05:00
sidebar_position: 40
2023-04-27 22:33:41 -05:00
aliases:
- /en-us/linux-service
2017-11-26 16:44:32 -05:00
---
# Run as a Linux service
2020-01-08 23:33:13 +07:00
You can run Gitea as a Linux 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).
2017-11-26 16:44:32 -05:00
## Using systemd
2018-01-08 16:48:42 -06:00
Copy the sample [gitea.service](https://github.com/go-gitea/gitea/blob/main/contrib/systemd/gitea.service) to `/etc/systemd/system/gitea.service`, then edit the file with your favorite editor.
2018-01-08 16:48:42 -06:00
Uncomment any service that needs to be enabled on this host, such as MySQL.
Change the user, home directory, and other required startup values. Change the
PORT or remove the -p flag if default port is used.
2019-03-09 16:15:45 -05:00
Enable and start Gitea at boot:
2022-07-28 03:22:47 +02:00
2017-11-26 16:44:32 -05:00
```
sudo systemctl enable gitea
2018-01-08 16:48:42 -06:00
sudo systemctl start gitea
```
2017-11-26 16:44:32 -05:00
2020-01-08 23:33:13 +07:00
If you have systemd version 220 or later, you can enable and immediately start Gitea at once by:
2022-07-28 03:22:47 +02:00
2020-01-08 23:33:13 +07:00
```
sudo systemctl enable gitea --now
```
2017-11-26 16:44:32 -05:00
## Using supervisor
2017-11-26 16:44:32 -05:00
2018-01-08 16:48:42 -06:00
Install supervisor by running below command in terminal:
2022-07-28 03:22:47 +02:00
2017-11-26 16:44:32 -05:00
```
sudo apt install supervisor
```
2018-01-08 16:48:42 -06:00
Create a log dir for the supervisor logs:
2022-07-28 03:22:47 +02:00
2018-01-08 16:48:42 -06:00
```
2019-03-09 16:15:45 -05:00
# assuming Gitea is installed in /home/git/gitea/
2018-01-08 16:48:42 -06:00
mkdir /home/git/gitea/log/supervisor
```
Append the configuration from the sample
[supervisord config](https://github.com/go-gitea/gitea/blob/main/contrib/supervisor/gitea) to `/etc/supervisor/supervisord.conf`.
2018-01-08 16:48:42 -06:00
Using your favorite editor, change the user (`git`) and home
(`/home/git`) settings to match the deployment environment. Change the PORT
2020-01-08 23:33:13 +07:00
or remove the -p flag if default port is used.
2018-01-08 16:48:42 -06:00
Lastly enable and start supervisor at boot:
2022-07-28 03:22:47 +02:00
2017-11-26 16:44:32 -05:00
```
sudo systemctl enable supervisor
2018-01-08 16:48:42 -06:00
sudo systemctl start supervisor
```
2020-01-08 23:33:13 +07:00
If you have systemd version 220 or later, you can enable and immediately start supervisor by:
2022-07-28 03:22:47 +02:00
2020-01-08 23:33:13 +07:00
```
sudo systemctl enable supervisor --now
```