Logo       PBase-Foundation

Gitea

Installation - Summary

Substitute your server's subdomain, email and optional SMTP credentials in the echo commands below. If your server is registered in DNS as your domain's root provide an empty string instead of "git" shown in the example. The echo commands to fill the DEFAULT_SMTP... files are optional and may be omitted. After providing these defaults run the yum commands as detailed below.

echo "git" > /root/DEFAULT_SUB_DOMAIN.txt
echo "myaddress@myemailprovider.com" > /root/DEFAULT_EMAIL_ADDRESS.txt
## optional - for outgoing email
echo "smtp.mailgun.org" > /root/DEFAULT_SMTP_SERVER.txt
echo "postmaster@mail.example.com" > /root/DEFAULT_SMTP_USERNAME.txt
echo "ureplac3-w1threalsmtp-pswrd" > /root/DEFAULT_SMTP_PASSWORD.txt
yum -y install https://pbase-foundation.com/pbase-repo.rpm
yum -y install pbase-preconfig-postgres-gitea
yum -y install pbase-postgres
yum -y install pbase-gitea
yum -y install pbase-lets-encrypt

Installation - Step by Step

Here is how to install an instance of the Gitea lightweight Git repository UI with Postgres database backend. It assumes your host is registered in DNS on a "git" subdomain like git.myexample.com and the installer will use Let's Encrypt to setup HTTPS.

Step 1: Provide your subdomain and admin email address by using the echo commands below to create a text file under the /root directory for each value. The DEFAULT_SMTP... values are optional.
For example:

echo "git" > /root/DEFAULT_SUB_DOMAIN.txt
echo "myaddress@myemailprovider.com" > /root/DEFAULT_EMAIL_ADDRESS.txt
echo "smtp.mailgun.org" > /root/DEFAULT_SMTP_SERVER.txt
echo "postmaster@mail.example.com" > /root/DEFAULT_SMTP_USERNAME.txt
echo "ureplac3-w1threalsmtp-pswrd" > /root/DEFAULT_SMTP_PASSWORD.txt

Step 2: Install the pbase-repo package with the command:
yum -y install https://pbase-foundation.com/pbase-repo.rpm

... when it runs, its output will point out the file pbase_repo.json that now holds copies of the defaults.

Step 3: Install the Gitea dependencies and pre-configuration package with the command:
yum -y install pbase-preconfig-postgres-gitea

Step 4: It's output will tell you to review pbase_smtp.json in the module-config.d directory:
vi /usr/local/pbase-data/admin-only/module-config.d/pbase_smtp.json

... if this file contains SMTP email server credentials the values will get copied to the Gitea initial configuration file.

Step 5: Install a local database with the pbase-postgres package:
yum -y install pbase-postgres

...or to configure a non-local Postgres instance you must edit pbase_postgres.json in the module-config.d directory instead to provide its connection information.

Step 6: Install the pbase-gitea package with the command:
yum -y install pbase-gitea

Step 7: If your host is registered in DNS, installing the pbase-lets-encrypt package will generate a certificate for HTTPS connections:
yum -y install pbase-lets-encrypt

When the pbase-gitea and pbase-lets-encrypt packages complete you should have a full working instance of Gitea ready to be administered at https://git.myexample.com depending on your domain name.

Step 8: Open the Gitea installation page and customize your instance. Your database installation details should already be in the Gitea initial configuration page ready to accept. https://git.myexample.com/install

Step 9: Be sure to register after the installation page completes and redirects to the login page. The first registered user becomes the administrator.

Extras

You should secure your server ports with pbase-firewall-enable and lock down SSH access with the pbase-ssh-fail2ban package.
If your server doesn't already have NTP/Chrony already running you should sync your clocks with the pbase-timesync-enable package.

yum -y install pbase-firewall-enable
yum -y install pbase-ssh-fail2ban
yum -y install pbase-timesync-enable

Gitea with MySQL

Using a MySQL database for the backend for Gitea is also supported.

echo "git" > /root/DEFAULT_SUB_DOMAIN.txt
echo "myaddress@myemailprovider.com" > /root/DEFAULT_EMAIL_ADDRESS.txt
yum -y install https://pbase-foundation.com/pbase-repo.rpm
yum -y install pbase-preconfig-mysql-gitea
yum -y install pbase-mysql
yum -y install pbase-gitea
yum -y install pbase-lets-encrypt

Compatibility

The pbase-gitea installer package has been tested on CentOS 7 and 8, Fedora 33, and Amazon Linux 2

Configuration Options

The first step of the installer is the pbase-repo package. It creates the module-config.d directory to hold customizable configuration option files:
/usr/local/pbase-data/admin-only/module-config.d/

The pbase-repo creates this file: pbase_repo.json
it must be edited to set the defaultEmailAddress field with your email.

{
"pbase_repo": {
"defaultEmailAddress": "myaddress@myexample.com",
"defaultDesktopUsername": "",
"defaultSmtpPassword": "9876543210987654321-87654321",
"defaultSubDomain": ""
}
}

The third step of the install is the pbase-preconfig-postgres-gitea package. It places more default option files described below under the /usr/local/pbase-data/admin-only/module-config.d/ directory.

This is the Gitea configuration options file: pbase_gitea.json
These defaults are appropriate for most use cases.

{
"pbase_gitea" : {
"giteaVersion": "",
"httpPort": 3000,
"addApacheProxy": true,
"database": "postgres",
"urlSubPath": "",
"disableRegistration": false,
"requireSigninView": false
}
}

The default configuration assumes Gitea web UI is the root of your site. But if you want to serve the UI under a subpath http://myexample.com/gitsubpath/ change the urlSubPath field.

(Limitations: changing the disableRegistration, requireSigninView, port or addNgnixProxy fields is not implemented in 1.0)


This is the Let's Encrypt configuration options file: pbase_lets_encrypt.json
The emailAddress gets copied from the pbase_repo.json set above. It assumes your host is assigned the subdomain of 'git' otherwise change it with the urlSubDomain field. (If your server is not registered in DNS you should set executeCertbotCmd to false.)

{
"pbase_lets_encrypt" : {
"enableAutoRenew": true,
"executeCertbotCmd": true,
"urlSubDomain": "git",
"additionalSubDomain": "",
"emailAddress": "yoursysadmin@yourrealmail.com"
}
}

(Limitations: the additionalSubDomain field is not implemented in 1.0)


This is the SMTP configuration options file: pbase_smtp.json
The defaults are typical for a client using the popular Mailgun service.
Be sure to set the password field with the correct value from the SMTP provider.

{
"pbase_smtp" : {
"server": "smtp.mailgun.org",
"port": 587,
"login": "postmaster@mail.example.com",
"password": "myrealsmtppassword",
"authMethod": "plain",
"openSSLVerifyMode": "none"
}
}

This is the Postgres configuration options file: pbase_postgres.json
The defaults are typical for a standalone Gitea server stack with a local Postgres server, and generally will not need to be modified.

But for an external database server this file must be edited. First, set the install field to false and provide the remote Postgres database's connection information.

{
"pbase_postgres": [
{
"default": {
"hostName": "localhost",
"port": "5432",
"startService": true,
"enableRemoteAccess": true,
"install": true,
"database": [
{
"name": "gitea",
"user": "gitea",
"password": "shomeddata",
"characterSet": "UTF8",
"grantCreateDatabase": false
}
]
}
}
]
}

(Limitations: only one database at a time, changing the startService, enableRemoteAccess fields are not implemented in 1.0)

Subdomain name

Your server's subdomain is defined in initial step of filling the /root/DEFAULT_SUB_DOMAIN.txt file. The value in this file is copied to the urlSubDomain field in the JSON preconfig pbase_apache.json and pbase_lets_encrypt.json files created in step three of the install.
The steps shown above assumes the 'git' subdomain is configured in DNS.

The other option is to have Gitea for your root domain.
In this case, simply set the DEFAULT_SUB_DOMAIN file to an empty string with:
echo "" > /root/DEFAULT_SUB_DOMAIN.txt

... or omit it which sets the preconfig files' urlSubDomain fields to an empty string.

More about Gitea

Visit the Gitea project at:
https://gitea.io/
"A painless self-hosted Git service. Gitea is a community managed lightweight code hosting solution written in Go..."