Gitea is a self-hosted Git service that allows you to easily host and manage your Git repositories. In this tutorial, we will guide you on how to install Gitea on Debian using some simple steps.
Before you proceed with the installation, make sure you have the following prerequisites:
We need to install some dependencies before we proceed with the Gitea installation. The following command will install all the required dependencies:
sudo apt update && sudo apt install -y git wget sqlite3
You can download the latest version of Gitea via the official website (https://dl.gitea.io/gitea) or via the command line. In this tutorial, we will download the latest version via the command line using the following command:
wget -O gitea https://dl.gitea.io/gitea/1.15.5/gitea-1.15.5-linux-amd64
You can check for the latest version on the official website and replace the version number in the above command. Once the download is complete, we need to make the Gitea binary executable:
chmod +x gitea
Now, we need to create a systemd service to run Gitea as a system service. Create a new systemd service file using the command below:
sudo nano /etc/systemd/system/gitea.service
Add the following content to the file:
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
# Requires=mysql.service
# Requires=mariadb.service
# Requires=postgresql.service
# Requires=memcached.service
# Requires=redis.service
[Service]
# Modify these two entries according to your user and group
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea/
# Assuming you store Gitea binary in /usr/local/bin,
# if not, update the path of the binary file
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
Restart=always
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
Replace the user and group to the user you want to run the Gitea service as. Save and close the file.
We need to create a user and group to run Gitea. Run the following command to create a new user:
sudo adduser --system --shell /bin/bash --comment 'Git Version Control' --user-group --home-dir /var/lib/gitea gitea
Before we can start Gitea, we need to create a configuration file app.ini
. Run the following command to create the file:
sudo mkdir /etc/gitea/
sudo nano /etc/gitea/app.ini
Add the following content to the file:
[server]
SSH_DOMAIN = localhost
DOMAIN = YOUR_DOMAIN_NAME
HTTP_PORT = 3000
ROOT_URL = http://${DOMAIN}:${HTTP_PORT}/
DISABLE_SSH = false
SSH_PORT = 22
START_SSH_SERVER = true
LFS_START_SERVER = true
LFS_CONTENT_PATH = /var/lib/gitea/data/lfs
PROTOCOL = http
CERT_FILE = /etc/gitea/cert.pem
KEY_FILE = /etc/gitea/key.pem
CUSTOM_HOME = /var/lib/gitea
LANDING_PAGE = home
SHOW_FOOTER = true
SHOW_BRANDING = true
SHOW_POWERED_BY = true
RUN_MODE = prod
[database]
DB_TYPE = sqlite3
# DB_HOST = 127.0.0.1:3306
DB_NAME = gitea
DB_USER = root
# Uncomment the following if you use MySQL or MariaDB
# DB_PASSWD =
# CHARACTER_SET = utf8mb4
# READ_TIMEOUT = 300s
# WRITE_TIMEOUT = 300s
# MAX_ALLOWED_PACKET = 4M
# STRICT = false
# OPTIONS =
[repository]
ROOT = /var/lib/gitea/repositories
SCRIPT_TYPE = bash
GIT_LFS_ENABLED = true
DISABLE_HTTP_GIT = false
HTTP_AUTH_MODE = digest
OVERLAPPING_ENABLED = false
[mailer]
ENABLED = false
[service]
DISABLE_REGISTRATION = false
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
ENABLE_REVERSE_PROXY_AUTHENTICATION = false
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
[security]
INSTALL_LOCK = true
SECRET_KEY = SECURE_RANDOM_KEY
INTERNAL_TOKEN = SECURE_RANDOM_KEY
COOKIE_USERNAME = false
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false
_ALLOWED_ORIGINS =
[log]
MODE = file
LEVEL = info
ROOT_PATH = /var/log/gitea
[log.console]
LEVEL = info
[log.file]
LEVEL = info
[session]
PROVIDER_CONFIG = /etc/gitea/sessions
[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = false
[attachment]
ENABLED = true
PATH = /var/lib/gitea/attachments
MAX_SIZE = 20
ALLOWED_TYPES = image/*,application/rar,application/zip,text/*,application/msword,application/vnd.ms-excel,application/vnd.ms-powerpoint
[other]
ENABLE_CAPTCHA = true
DEFAULT_KEEP_EMAIL_PRIVATE = false
[ui]
DEFAULT_THEME = arc-green
SHOW_USER_PROFILE_NOT_ACTIVE_YET = true
Replace the DOMAIN
value with the domain or subdomain pointing to your server IP address. Save and close the file.
Now, we need to create a data directory for Gitea. Run the following command to create the directory:
sudo mkdir /var/lib/gitea/
sudo chown gitea: -R /var/lib/gitea/
We need to allow traffic on port 3000
and 22
for Gitea to work properly. Run the following command to allow the traffic:
sudo ufw allow 3000/tcp
sudo ufw allow ssh
Finally, we can start the Gitea service using the following command:
sudo systemctl daemon-reload
sudo systemctl start gitea
sudo systemctl enable gitea
Gitea is now installed and running on your Debian system. You can now access the Gitea web interface by going to http://<YOUR_IP>:3000
in your web browser.
In this tutorial, we have successfully installed Gitea on Debian server. You can now use Gitea to manage your Git repositories on your own server.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!