Gitea Multi-Instance for Ubuntu 24.04 Server
Automated Bash installer script for deploying multiple Gitea instances on Ubuntu 24.04 Server.
Prerequisites
Nginx as well as MariaDB. Nginx can be installed from here and MariaDB from here.
Important
For each Gitea instance (each run of this script), the following rules apply:
- Each instance will have its own user, e.g. gitea1, gitea2, etc.
- Each instance will have its own local port, e.g. 3001, 3002, etc.
- Each instance will have its own configuration file, e.g. /etc/giteauser1/app.ini.
- Each instance will have its own service unit, e.g. gitea1.service, gitea2.service.
- All instances share the same Gitea executable. Updating it requires notifying all instance owners.
Logic
-
The first instance will be called gitea1 with:
- Port: 3001
- Database: gitea1db
- Service: gitea1.service
-
The second instance will be called gitea2 with:
- Port: 3002
- Database: gitea2db
- Service: gitea2.service
The script automatically picks the next instance number. If gitea1 already exists, it will choose gitea2, and so on.
Be sure to run each script completely — this includes finishing the initial configuration in your browser and running the post-install script — before starting another instance of this script.
Download the Script
git clone https://git.x-files.dk/ubuntu-web-application/gitea-multi-multi.git
Usage
cd gitea-ubuntu-multi
sudo ./giteainstall [-n] <domain name> [-p] <gitea database password>
Example
sudo ./giteainstall -n git.something.xyz -p giteadatabasepwd
This creates a Gitea site running on port 80 with the specified domain name. For HTTPS setup, see the Nginx example here. Also update /etc/gitea/app.ini (change http to https), then restart Nginx and the Gitea instance.
Configuration
Once the script is done, browse to:
http://git.something.xyz
and complete the mandatory fields marked in green.
Post-install
Run the following to adjust app.ini
after the initial setup:
sudo /tmp/gitea-postinstall
Notes
- SSH will be disabled after running postinstall. You can modify this in /etc/gitea/app.ini.
- Custom assets (favicon, logo) must be placed in: /var/lib/gitea/custom/public/assets/img/
- To serve a custom splash page, create home.tmpl and place it in: /var/lib/gitea/custom/templates/
Troubleshooting
Most issues are likely due to differences in Nginx configuration. If you encounter problems, compare with the Nginx configuration I use here and the default sites-enabled config here.
Q and A
Q: Why does the script need the MariaDB root password?
A: To create the Gitea database and set the correct permissions.
More Guides
More guides can be found on wiki.x-files.dk