code.gitea.io/gitea@v1.22.3/docs/content/installation/run-as-service-in-ubuntu.en-us.md (about)

     1  ---
     2  date: "2017-07-21T12:00:00+02:00"
     3  title: "Run as a Linux service"
     4  slug: "linux-service"
     5  sidebar_position: 40
     6  toc: false
     7  draft: false
     8  aliases:
     9    - /en-us/linux-service
    10  menu:
    11    sidebar:
    12      parent: "installation"
    13      name: "Linux service"
    14      sidebar_position: 40
    15      identifier: "linux-service"
    16  ---
    17  
    18  # Run as a Linux service
    19  
    20  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).
    21  
    22  ## Using systemd
    23  
    24  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.
    25  
    26  Uncomment any service that needs to be enabled on this host, such as MySQL.
    27  
    28  Change the user, home directory, and other required startup values. Change the
    29  PORT or remove the -p flag if default port is used.
    30  
    31  Enable and start Gitea at boot:
    32  
    33  ```
    34  sudo systemctl enable gitea
    35  sudo systemctl start gitea
    36  ```
    37  
    38  If you have systemd version 220 or later, you can enable and immediately start Gitea at once by:
    39  
    40  ```
    41  sudo systemctl enable gitea --now
    42  ```
    43  
    44  ## Using supervisor
    45  
    46  Install supervisor by running below command in terminal:
    47  
    48  ```
    49  sudo apt install supervisor
    50  ```
    51  
    52  Create a log dir for the supervisor logs:
    53  
    54  ```
    55  # assuming Gitea is installed in /home/git/gitea/
    56  mkdir /home/git/gitea/log/supervisor
    57  ```
    58  
    59  Append the configuration from the sample
    60  [supervisord config](https://github.com/go-gitea/gitea/blob/main/contrib/supervisor/gitea) to `/etc/supervisor/supervisord.conf`.
    61  
    62  Using your favorite editor, change the user (`git`) and home
    63  (`/home/git`) settings to match the deployment environment. Change the PORT
    64  or remove the -p flag if default port is used.
    65  
    66  Lastly enable and start supervisor at boot:
    67  
    68  ```
    69  sudo systemctl enable supervisor
    70  sudo systemctl start supervisor
    71  ```
    72  
    73  If you have systemd version 220 or later, you can enable and immediately start supervisor by:
    74  
    75  ```
    76  sudo systemctl enable supervisor --now
    77  ```