Files
gitea-ubuntu-multi/README.md

222 lines
5.4 KiB
Markdown
Raw Normal View History

2025-12-19 15:31:57 +01:00
# Gitea MultiInstance for Ubuntu 24.04
[![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)](#)
[![MariaDB](https://img.shields.io/badge/db-mariadb-003545)](#)
[![MySQL](https://img.shields.io/badge/db-mysql-4479A1)](#)
[![Gitea](https://img.shields.io/badge/app-gitea-609926)](#)
[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
Install multiple Gitea instances on Ubuntu 24.04 server.
This is not a demo environment.
This is a production-focused installer built to scale cleanly and update centrally.
## Why this installer exists
Running several Gitea instances on one server should be easy. This script makes multi-instance hosting repeatable.
## What this installer does
✔ Auto-numbers instances (gitea1, gitea2 …)
✔ Creates isolated DB + service per instance
✔ Assigns final ports safely post-install
✔ Includes robots + sitemap generation
✔ Shared binary — one upgrade updates all
## What this installer does *NOT* do
It wont stop you from running the script without reading the documentation like theres no tomorrow.
Skip the README, and whatever happens next is your headache, not a bug report.
---
## Requirements
You must already have:
✔ Nginx installed
✔ MariaDB/MySQL running
✔ Port **3000 free during install** (temporary only)
### Optional Installers (if you need them — saves you some googling)
- [Install Nginx + PHP-FPM on Ubuntu](https://git.x-files.dk/webserver/nginx-ubuntu)
- [Install MariaDB on Ubuntu](https://git.x-files.dk/database/mariadb-ubuntu)
- [Install MySQL on Ubuntu](https://git.x-files.dk/database/mysql-ubuntu)
---
## 1. Download
```
git clone https://git.x-files.dk/webapps/gitea-ubuntu-multi.git
```
```
cd gitea-ubuntu-multi
```
---
## 2. Install a new instance
```
2026-01-01 16:59:45 +01:00
sudo ./giteainstall -n <domain> -p <dbpassword> [options]
2025-12-19 15:31:57 +01:00
```
### Examples
Socket auth present:
```
2026-01-01 16:59:45 +01:00
sudo ./giteainstall -n git1.example.com -p gitea1pwd
2025-12-19 15:31:57 +01:00
```
No socket → use DB credentials:
```
2026-01-01 16:59:45 +01:00
sudo ./giteainstall -n git2.example.com -p pass2 -m rootpwd
2025-12-19 15:31:57 +01:00
```
### Flags
| Option | Meaning |
|---|---|
| `-p` password | DB password for the new Gitea instance |
| `-m` password | Admin/root MariaDB password *(if no socket)* |
| `-a` username | Admin DB user *(default = root)* |
| `-h` | Help screen |
---
## How instances are created
Each install assigns the **next instance number automatically**:
| Instance | User | DB | Config | Service | Final Port |
|---|---|---|---|---|---|
| 1 | gitea1 | gitea1db | /etc/gitea1 | gitea1.service | 3001 |
| 2 | gitea2 | gitea2db | /etc/gitea2 | gitea2.service | 3002 |
| 3 | gitea3 | gitea3db | /etc/gitea3 | gitea3.service | 3003 |
Temporary installer UI runs at `http://domain:3000`
Final port assigned **after postinstall**.
---
## Complete setup
1. Visit:
```
http://<domain>
```
2. Finish the web installer WITHOUT changing port.
3. Run the postinstall unique to this instance:
```
sudo /etc/giteaX/gitea-postinstall
```
(`X` = instance number)
That step:
✔ moves Gitea from 3000 → final assigned port
✔ configures logging, UI, paging, themes
✔ disables SSH by default
✔ updates Nginx proxy target
---
## File Layout (auto-increment per instance)
When first installed, paths look like this:
**Instance 1**
| Path | Purpose |
|---|---|
| `/etc/gitea1/app.ini` | Main config file |
| `/etc/gitea1/gitea-postinstall` | Postinstall script |
| `/var/lib/gitea1/` | Data, repos, indexers, logs |
| `/var/lib/gitea1/custom/templates/` | UI overrides |
| `/var/lib/gitea1/custom/public/assets/img/` | Logos + branding |
| `/var/lib/gitea1/custom/public/` | robots + sitemap *(optional)* |
| `/usr/local/bin/gitea` | Shared binary |
**Instance 2 (identical structure, next number auto-assigned)**
| Path | Purpose |
|---|---|
| `/etc/gitea2/app.ini` | Main config file |
| `/etc/gitea2/gitea-postinstall` | Postinstall script |
| `/var/lib/gitea2/` | Data, repos, indexers, logs |
| `/var/lib/gitea2/custom/templates/` | UI overrides |
| `/var/lib/gitea2/custom/public/assets/img/` | Logos + branding |
| `/var/lib/gitea2/custom/public/` | robots + sitemap *(optional)* |
| `/usr/local/bin/gitea` | Shared binary |
> Every new install increments automatically (`gitea3`, `gitea4`, `gitea5`…)
> Important (but optional):
> `robots.txt` and `sitemap.xml` are supported automatically by the Nginx configuration being created,
> however the installer does not generate these files. Create them manually in the directory listed above.
---
## HTTPS
Use the TLS template here:
https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/gitea.443.conf
Then update in `/etc/giteaX/app.ini`:
```
ROOT_URL = https://<domain>
```
Restart:
```
systemctl restart giteaX nginx
```
---
## Version Handling
Script checks latest from:
```
https://dl.gitea.com/gitea/version.json
```
Fallback file contains static version:
```
fallback
1.25.2
```
---
## Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
| Nginx restart fails | Bad config | `nginx -t` |
| DB denied | No socket | Add `-m` (and `-a`) |
| Blank web UI | Service down | `systemctl status giteaX` |
| Next instance reusing port | Postinstall not run | Run `/etc/giteaX/gitea-postinstall` |
---
### More Information
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
---
### License
Licensed under the [MIT License](./LICENSE).
---