Files

155 lines
6.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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&emsp;Edit&emsp;View&emsp;Favorites&emsp;Tools&emsp;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 yall 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 dont care for Docker personally, and
with a PostgreSQL database as opposed to something like SQLite, as
thats the database I prefer to use when I have to use one (Im 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 claritys 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>Well also assume <code>nano</code> will be used for editing files,
but you can use whatever text editor you prefer</p>
<p>Were also going to assume you already have a domain name pointed at
the server you are doing this on (well 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 were gonna need to do, since were not using something
like Docker, or just using the standalone binary, is add the third-party
repo for Gitea</p>
<p>First up, well 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, well add the repo by creating/editing the <code>.source</code>
file that will contain the repos 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 well update apt so it can refresh its 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, well 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 were gonna edit PostgreSQLs 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, were 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, well restart PostgreSQL</p>
<pre><code># sytemctl restart postgresql</code></pre>
<p>Now, to actually setup and configure the database</p>
<p>First, well 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 &#39;password&#39;</code></pre>
<p>Next, the database</p>
<pre><code>CREATE DATABASE gitea WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE &#39;en_US.UTF-8&#39; LC_CTYPE &#39;en_US.UTF-8&#39;;</code></pre>
<p>Now exit <code>psql</code></p>
<pre><code>exit</code></pre>
<h2 id="configure-caddy">Configure Caddy</h2>
<p>Were 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 well 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>