docs: clearer README, more user-friendly

This commit is contained in:
2025-11-27 16:18:17 +01:00
parent d93a2b13bc
commit cd075ad2af

181
README.md
View File

@@ -1,4 +1,4 @@
# Gitea for Ubuntu 24.04 Server
# Gitea on Ubuntu 24.04 Server
[![OS](https://img.shields.io/badge/ubuntu-24.04-E95420)](#)
[![Shell](https://img.shields.io/badge/shell-bash-121011)](#)
[![WebServer](https://img.shields.io/badge/server-nginx-009639)](#)
@@ -7,52 +7,44 @@
[![Server](https://img.shields.io/badge/server-gitea-609926)](#)
[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
Installs and configures the **latest available Gitea release** on Ubuntu 24.04 Server.
Production-ready automated installation of **Gitea on Ubuntu 24.04**.
Database, Nginx host config, systemd service & post-install hardening included.
This is a **production-focused installer**, not a demo.
It assumes Nginx, and either MariaDB or MySQL are already installed and running.
This script works with both MariaDB and MySQL, with or without socket authentication.
This is not a demo environment.
This script deploys a **real Gitea server** — safely, repeatedly, and without hand-editing configs.
---
## Related Installers
## Requirements
If you dont have the required components, you can use these compatible installers:
✔ Nginx installed
✔ MariaDB/MySQL running (socket or password supported)
- [Nginx Installer](https://git.x-files.dk/webserver/nginx-ubuntu)
- [MariaDB Installer](https://git.x-files.dk/database/mariadb-ubuntu)
Related installers:
https://git.x-files.dk/webserver/nginx-ubuntu
https://git.x-files.dk/database/mariadb-ubuntu
> **NOTE**
> If you plan to host multiple Gitea instances on the same server, see the [multi-instance installer](https://git.x-files.dk/webapps/gitea-ubuntu-multi).
Multi-instance hosting:
https://git.x-files.dk/webapps/gitea-ubuntu-multi
---
### Download the Script
Clone this repository to your server:
## 1. Clone
```
git clone https://git.x-files.dk/webapps/gitea-ubuntu.git
```
```
cd gitea-ubuntu
```
### Usage
---
Run the script using:
## 2. Install
```
sudo ./giteainstall -n <domain> -p <gitea db password> [options]
```
### Examples
The installer automatically detects if socket authentication is active.
Only include `-a` and `-m` if your MariaDB setup does **not** use socket authentication.
Examples:
```
sudo ./giteainstall -n git.example.com -p giteadbpass
@@ -60,116 +52,96 @@ sudo ./giteainstall -n git.example.com -p giteadbpass -m rootpwd
sudo ./giteainstall -n git.example.com -p giteadbpass -a admin -m adminpwd
```
---
Options:
### Options
| Flag | Description |
|------|--------------|
| `-p <password>` | Gitea database user password |
| `-a <username>` | Optional MariaDB admin username (defaults to `root` if not specified) |
| `-m <password>` | MariaDB root or admin password — *required only if socket authentication is disabled* |
| `-h`, `--help` | Show the help screen (reflects detected socket status) |
| Flag | Meaning |
|---|---|
| `-p <password>` | Gitea DB user password |
| `-m <password>` | MariaDB admin/root password *(socket OFF)* |
| `-a <username>` | DB admin username (default `root`) |
| `-h` | Help |
---
### Configuration
## After Installation
When the installation completes, visit:
Visit:
```
http://<domain>
```
and complete the initial Gitea setup through the web interface.
Then finalize setup and run:
---
### Post-install
After the web installer is done run:
```bash
```
sudo /tmp/gitea-postinstall
```
This adjusts log levels, upload limits, disables SSH access and other tweaks.
SSH is disabled by default after post-install (modify `/etc/gitea/app.ini` if needed).
This applies safe defaults, log tuning, upload limit changes, disables SSH by default.
---
### Notes
- Custom assets (favicon, logo, etc.) go in: `/var/lib/gitea*/custom/public/assets/img/`
- Custom homepage template: `/var/lib/gitea*/custom/templates/home.tmpl`
---
### Nginx Integration
The generated Gitea configuration file listens on port 80.
To enable HTTPS (port 443), use the example provided [here](https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/gitea.443.conf).
> **IMPORTANT**
> If you enable HTTPS, update `/etc/gitea/app.ini` (`ROOT_URL` setting)
> from `http` to `https`, then restart both Nginx and Gitea.
> **NOTE**
> The file also includes optional caching directives (commented out by default).
> You can enable them to improve load times and performance if needed.
> The lines you are looking for are at the bottom of the generated config file and look like this:
> ```
> ##### Cache js css static content and open files start #####################
> # include /etc/nginx/nginx-snippets/cache-open-files.conf;
> # include /etc/nginx/nginx-snippets/cache-statics.conf;
> # include /etc/nginx/nginx-snippets/cache-js-css.conf;
> ##### Cache js css static content and open files stop ######################
> ```
---
### Version Handling
This installer automatically checks the latest **Gitea version** from [https://dl.gitea.com/gitea/version.json](https://dl.gitea.com/gitea/version.json)
If it fails, it falls back to the version number stored in the **`fallback`** file. That file contains one line, for example:
Re-enable SSH in:
```
1.24.6
/etc/gitea/app.ini
```
> **Why a separate file?**
> Keeping the fallback version outside the script avoids polluting the code with constants.
> This keeps updates clean and ensures the installer logic never changes just because a version bump is needed.
---
## File Locations
| Path | Purpose |
|---|---|
| `/var/lib/gitea/custom/public/assets/img/` | Custom images |
| `/var/lib/gitea/custom/templates/home.tmpl` | Home override |
| `/etc/gitea/app.ini` | Main config file |
| `/etc/nginx/conf.d/<domain>.conf` | Vhost generated |
---
### Troubleshooting
## HTTPS
**Nginx fails to restart**
Run `nginx -t` and review any syntax errors reported in `/etc/nginx/conf.d/<domain>.conf`.
Enable TLS:
**Gitea front-end not loading**
Run `systemctl status gitea nginx` and ensure both Gitea and Nginx services are active:
https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/gitea.443.conf
**Access denied during database creation**
Your MariaDB setup likely does not use socket authentication.
Re-run the installer with the `-m` flag (and optionally `-a`) to provide credentials.
Then set:
```
ROOT_URL = https://<domain>
```
Restart:
```
systemctl restart gitea nginx
```
---
### FAQ
## Version Detection
**Q:** Why doesnt the script ask for a MariaDB password by default?
**A:** Ubuntu 24.04s MariaDB installation defaults to *socket authentication*,
allowing the local `root` user to connect without a password.
The installer detects this automatically and skips password prompts when applicable.
Pulls latest from:
**Q:** Can I run the installer multiple times?
**A:** Yes. Database and user creation use `IF NOT EXISTS`, making them safe to re-run.
Existing configuration files are replaced, but no data is deleted.
https://dl.gitea.com/gitea/version.json
**Q:** Does this modify existing Nginx settings?
**A:** No. It adds a standalone host file in `/etc/nginx/conf.d/`
and validates configuration changes before applying them.
Fallback uses file:
```
fallback
1.25.2
```
---
## Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Nginx restart fails | Config error | `nginx -t` |
| DB denied | No socket auth | Add `-m` |
| UI blank | Gitea service down | `systemctl status gitea` |
Safe to re-run — DB creation checks exist first.
---
@@ -180,7 +152,6 @@ More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-f
---
### License
Licensed under the [MIT License](./LICENSE).
---