155 lines
6.4 KiB
HTML
155 lines
6.4 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>
|
||
[ Setup Gitea on Debian | easthighNerd ]
|
||
</title>
|
||
<link href="/res/css/default.css" rel="stylesheet">
|
||
<link href="/res/img/favicon.gif" rel="icon" type="image/gif">
|
||
<link rel="me" href="https://raru.re/@easthighNerd">
|
||
</head>
|
||
<body class="window">
|
||
<div class="window_bar">
|
||
<p>
|
||
Setup Gitea on Debian
|
||
</p>
|
||
<a href="/home/" class="close_button">
|
||
<img src="/res/img/close.png" width="48px" height="48px" alt="Close button">
|
||
</a>
|
||
<div class="explorer_bar_top">
|
||
<div class="menu_bar">
|
||
<p>
|
||
File Edit View Favorites Tools Help
|
||
</p>
|
||
</div>
|
||
<div class="navigation_bar">
|
||
<p>
|
||
<a href="/blog/" class="back_button">
|
||
<img src="/res/img/back.png" width="23px" height="23px" alt="Back button">
|
||
Back
|
||
</a>
|
||
</p>
|
||
</div>
|
||
<div class="address_bar">
|
||
<p>
|
||
https://www.easthighnerd.net/
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="window_content">
|
||
<h1 id="setup-gitea-on-debian">Setup Gitea on Debian</h1>
|
||
<p>I just recently setup a new Gitea server for myself, and I would like
|
||
to share with y’all on how to do the same</p>
|
||
<p>This was done on a fresh Debian 12 cheapo VPS on Linode, so this
|
||
guide will pretty much apply to any Debian (and likely Ubuntu) system
|
||
that is more-or-less a stock installation</p>
|
||
<p>I did this using
|
||
<a href="https://gitlab.com/packaging/gitea/" target="_blank">a
|
||
third-party repository for Gitea</a> that was
|
||
<a href="https://www.gitea.com/gitea/awesome-gitea/src/branch/main/README.md#user-content-packages/" target="blank">linked
|
||
from the official site</a>, as I don’t care for Docker personally, and
|
||
with a PostgreSQL database as opposed to something like SQLite, as
|
||
that’s the database I prefer to use when I have to use one (I’m not a
|
||
big database person either)</p>
|
||
<p>Caddy will be used for the webserver as well, as it handles automatic
|
||
TLS certificate acquisition, and is easy to setup</p>
|
||
<p>For clarity’s sake, any command that starts with a <code>#</code> has
|
||
to be run either as root or with <code>sudo</code>, and any command that
|
||
starts with <code>$</code> can be run as a normal user (neither
|
||
<code>#</code> nor <code>$</code> are part of the actual command
|
||
itself)</p>
|
||
<p>We’ll also assume <code>nano</code> will be used for editing files,
|
||
but you can use whatever text editor you prefer</p>
|
||
<p>We’re also going to assume you already have a domain name pointed at
|
||
the server you are doing this on (we’ll use <code>git.example.net</code>
|
||
as a placeholder)</p>
|
||
<h2 id="overview">Overview</h2>
|
||
<ol type="1">
|
||
<li><a href="#adding-a-repo-for-installing-gitea">Adding a repo for
|
||
installing Gitea</a></li>
|
||
<li><a href="#install-gitea-postgresql-and-caddy">Install Gitea,
|
||
PostgreSQL, and Caddy</a></li>
|
||
<li><a href="#configure-postgresql">Configure PostgreSQL</a></li>
|
||
<li><a href="#configure-caddy">Configure Caddy</a></li>
|
||
<li><a href="#setup-gitea">Setup Gitea</a></li>
|
||
</ol>
|
||
<h2 id="adding-a-repo-for-installing-gitea">Adding a Repo for Installing
|
||
Gitea</h2>
|
||
<p>First thing we’re gonna need to do, since we’re not using something
|
||
like Docker, or just using the standalone binary, is add the third-party
|
||
repo for Gitea</p>
|
||
<p>First up, we’ll download the GPG key for the repo</p>
|
||
<pre><code># curl -sL -o /etc/apt/trusted.gpg.d/morph027-gitea.asc https://packaging.gitlab.io/gitea/gpg.key</code></pre>
|
||
<p>Then, we’ll add the repo by creating/editing the <code>.source</code>
|
||
file that will contain the repo’s information in <code>deb822</code>
|
||
format</p>
|
||
<pre><code># nano /etc/apt/sources.list.d/morph027-gitea.sources</code></pre>
|
||
<pre><code>Types: deb
|
||
URIs: https://packaging.gitlab.io/gitea
|
||
Suites: gitea
|
||
Components: main
|
||
Signed-By: /etc/apt/trusted.gpg.d/morph027-gitea.asc
|
||
Enabled: yes</code></pre>
|
||
<p>Now we’ll update apt so it can refresh it’s list of known
|
||
packages</p>
|
||
<pre><code># apt update</code></pre>
|
||
<h2 id="install-gitea-postgresql-and-caddy">Install Gitea, PostgreSQL,
|
||
and Caddy</h2>
|
||
<p>Now for the easiest part, we’ll install Gitea, our PostgreSQL
|
||
database, and our Caddy webserver</p>
|
||
<pre><code># apt install gitea postgresql caddy</code></pre>
|
||
<h2 id="configure-postgresql">Configure PostgreSQL</h2>
|
||
<p>Now for configuring PostgreSQL</p>
|
||
<p>First we’re gonna edit PostgreSQL’s config file</p>
|
||
<pre><code># nano /etc/postgresql/15/main/postgresql.conf</code></pre>
|
||
<p>and go to line 96, and uncomment</p>
|
||
<pre><code>#password_encryption = scram-sha-256 # scram-sha-256 or md5</code></pre>
|
||
<p>Next, we’re gonna edit</p>
|
||
<pre><code># nano /etc/postgresql/15/main/pg_hba.conf</code></pre>
|
||
<p>and add at the bottom of the file</p>
|
||
<pre><code>local gitea gitea scram-sha-256</code></pre>
|
||
<p>Now, we’ll restart PostgreSQL</p>
|
||
<pre><code># sytemctl restart postgresql</code></pre>
|
||
<p>Now, to actually setup and configure the database</p>
|
||
<p>First, we’ll need to run <code>psql</code> as the
|
||
<code>postgres</code> user</p>
|
||
<pre><code>$ sudo -u postgres psql</code></pre>
|
||
<p>Now, we need to create the “role” (user) that PostgreSQL will use for
|
||
interfacing with the database, replacing <code>password</code> with the
|
||
password you want to assign it</p>
|
||
<pre><code>CREATE ROLE gitea WITH LOGIN PASSWORD 'password'</code></pre>
|
||
<p>Next, the database</p>
|
||
<pre><code>CREATE DATABASE gitea WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';</code></pre>
|
||
<p>Now exit <code>psql</code></p>
|
||
<pre><code>exit</code></pre>
|
||
<h2 id="configure-caddy">Configure Caddy</h2>
|
||
<p>We’re gonna edit the main Caddyfile and configure it to simply
|
||
reverse proxy traffic to our new Gitea server</p>
|
||
<pre><code># nano /etc/caddy/Caddyfile</code></pre>
|
||
<p>Comment out/delete the contents of the file and put in</p>
|
||
<pre><code>git.example.net {
|
||
reverse_proxy localhost:3000
|
||
}</code></pre>
|
||
<p>And now we’ll restart Caddy</p>
|
||
<pre><code># systemctl restart caddy</code></pre>
|
||
<h2 id="setup-gitea">Setup Gitea</h2>
|
||
<hr>
|
||
<p>
|
||
<img src="/res/img/badges/by-sa.svg" class="cc_badge">
|
||
<br>
|
||
CC BY-SA 4.0
|
||
</p>
|
||
<p>
|
||
This work is licensed under a <a href="https://creativecommons.org/licenses/by-sa/4.0/" class="external_link" target="_blank">Creative Commons Attribution-ShareAlike 4.0 International License</a>
|
||
</p>
|
||
</div>
|
||
<div class="explorer_bar_bottom">
|
||
<p>
|
||
https://www.easthighnerd.net/
|
||
</p>
|
||
</div>
|
||
</body>
|
||
</html>
|