it-wiki:git:gitea
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
it-wiki:git:gitea [2020/02/06 11:32] – marko | it-wiki:git:gitea [2020/02/11 09:29] (aktuell) – [Step 1: Preparing the system] marko | ||
---|---|---|---|
Zeile 30: | Zeile 30: | ||
Next, create a user to run Gitea: | Next, create a user to run Gitea: | ||
<code bash> | <code bash> | ||
- | adduser --system | + | adduser --system --shell /bin/bash --home /home/gitea gitea |
</ | </ | ||
Zeile 66: | Zeile 66: | ||
===== Step 3: Installing Gitea ===== | ===== Step 3: Installing Gitea ===== | ||
Download the latest linux-amd64 binary from [[https:// | Download the latest linux-amd64 binary from [[https:// | ||
+ | <code bash> | ||
+ | wget https:// | ||
+ | chmod 755 / | ||
+ | </ | ||
+ | |||
+ | Next, create a systemd unit file for Gitea: | ||
+ | <code bash> | ||
+ | $EDITOR / | ||
+ | </ | ||
+ | |||
+ | And enter the following: | ||
+ | <code bash> | ||
+ | [Unit] | ||
+ | Description=Gitea (Git with a cup of tea) | ||
+ | After=syslog.target | ||
+ | After=network.target | ||
+ | Requires=postgresql.service | ||
+ | [Service] | ||
+ | Type=simple | ||
+ | User=gitea | ||
+ | Group=gitea | ||
+ | WorkingDirectory=/ | ||
+ | RuntimeDirectory=gitea | ||
+ | ExecStart=/ | ||
+ | Restart=always | ||
+ | Environment=USER=gitea HOME=/ | ||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | Make sure the new unit is loaded: | ||
+ | <code bash> | ||
+ | systemctl daemon-reload | ||
+ | </ | ||
+ | |||
+ | Then instruct systemd to start Gitea at system startup: | ||
+ | <code bash> | ||
+ | systemctl enable gitea.service | ||
+ | </ | ||
+ | |||
+ | ===== Step 4: Configuring Gitea ===== | ||
+ | For the initial configuration, | ||
+ | <code bash> | ||
+ | systemctl start gitea.service | ||
+ | </ | ||
+ | |||
+ | Then navigate to http:// | ||
+ | * Database Type: PostgreSQL | ||
+ | * Host: 127.0.0.1: | ||
+ | * Username: gitea | ||
+ | * Password: Enter the password you chose during Postgres role creation. | ||
+ | * Database Name: gitea | ||
+ | * SSL: Disable | ||
+ | * Site Title: Title of your choice. | ||
+ | * Repository Root Path: / | ||
+ | * Git LFS Root Path: / | ||
+ | * Run As Username: gitea | ||
+ | * SSH Server Domain: your_domain | ||
+ | * SSH Server Port: 22 | ||
+ | * Gitea HTTP Listen Post: 3000 | ||
+ | * Gitea Base URL: https:// | ||
+ | * Log Path: / | ||
+ | |||
+ | Configure email and the remaining settings as deemed fit, then click " | ||
+ | |||
+ | Stop Gitea before proceeding: | ||
+ | <code bash> | ||
+ | systemctl stop gitea.service | ||
+ | </ | ||
+ | |||
+ | Tighten permissions on /etc/gitea as shown below. This prevents anyone not in the gitea group from reading app.ini, which contains sensitive information, | ||
+ | <code bash> | ||
+ | chmod 750 /etc/gitea | ||
+ | chown root:gitea / | ||
+ | chmod 640 / | ||
+ | </ | ||
+ | |||
+ | Open its configuration file: | ||
+ | <code bash> | ||
+ | $EDITOR / | ||
+ | </ | ||
+ | |||
+ | Remove the following line from the [server] section: | ||
+ | <code bash> | ||
+ | HTTP_PORT = 3000 | ||
+ | </ | ||
+ | |||
+ | And add the following lines to the [server] section: | ||
+ | < | ||
+ | HTTP_ADDR | ||
+ | PROTOCOL | ||
+ | UNIX_SOCKET_PERMISSION = 666 | ||
+ | </ | ||
+ | |||
+ | ===== Step 5: Setting Up the Reverse Proxy ===== | ||
+ | Stop Nginx if it is running, as certbot will need to bind to port 80: | ||
+ | <code bash> | ||
+ | systemctl stop nginx.service | ||
+ | </ | ||
+ | |||
+ | Use the following command to obtain a certificate for your domain: | ||
+ | <code bash> | ||
+ | certbot certonly --standalone --agree-tos -m your_email@example.com -d your_domain | ||
+ | </ | ||
+ | |||
+ | Let's Encrypt will verify domain ownership before issuing the certificate. Your certificate, | ||
+ | |||
+ | We can now configure Nginx. Create a new configuration file: | ||
+ | <code bash> | ||
+ | $EDITOR / | ||
+ | </ | ||
+ | |||
+ | And enter the following configuration: | ||
+ | <code bash> | ||
+ | server { | ||
+ | listen 80; | ||
+ | listen [::]:80; | ||
+ | server_name your_domain; | ||
+ | return 301 https:// | ||
+ | access_log / | ||
+ | error_log / | ||
+ | } | ||
+ | server { | ||
+ | listen 443 ssl; | ||
+ | listen [::]:443 ssl; | ||
+ | server_name your_domain; | ||
+ | ssl on; | ||
+ | ssl_certificate / | ||
+ | ssl_certificate_key / | ||
+ | location / { | ||
+ | proxy_pass http:// | ||
+ | } | ||
+ | access_log / | ||
+ | error_log / | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | The first server block simply serves to redirect all HTTP requests to HTTPS. The second block listens for HTTPS connections and proxies them to the unix socket on which we configured Gitea to listen. | ||
+ | |||
+ | Once you've saved the above configuration, | ||
+ | <code bash> | ||
+ | ln -s / | ||
+ | </ | ||
+ | |||
+ | Check for any syntax errors with and edit your configuration accordingly: | ||
+ | <code bash> | ||
+ | nginx -t | ||
+ | </ | ||
+ | |||
+ | Finally, start Nginx and Gitea: | ||
+ | <code bash> | ||
+ | systemctl start nginx.service gitea.service | ||
+ | </ | ||
+ | |||
+ | Your Gitea instance should now be running successfully. If you did not create an administrator account using the initial web installer, the first user to sign up will be given the administrator role. | ||
+ | |||
+ | ===== Optional Steps ===== | ||
+ | ==== Logging Configuration ==== | ||
+ | By default, Gitea logs messages of severity level Info and above. You will most likely want to change that to Warn or Error. To do so, open / | ||
+ | <code bash> | ||
+ | [log] | ||
+ | MODE = file | ||
+ | LEVEL = warn | ||
+ | ROOT_PATH = / | ||
+ | </ | ||
+ | |||
+ | Restart Gitea for the changes to take effect: | ||
+ | <code bash> | ||
+ | systemctl restart gitea.service | ||
+ | </ | ||
+ | |||
+ | ==== Separate SSH server ==== | ||
+ | Gitea can alternatively use its own SSH server. To enable it, add the following line to the [server] configuration section: | ||
+ | |||
+ | <code bash> | ||
+ | START_SSH_SERVER = true | ||
+ | </ | ||
+ | |||
+ | And change the SSH port to any number above 1000, for instance: | ||
+ | <code bash> | ||
+ | SSH_PORT = 2222 | ||
+ | </ | ||
+ | |||
+ | Then restart Gitea to apply the changes. |
it-wiki/git/gitea.1580988729.txt.gz · Zuletzt geändert: von marko