Verified Commit 667fa245 authored by Elias Ojala's avatar Elias Ojala
Browse files

Draft of Gitea installation guide

parent b449f177
......@@ -10,3 +10,227 @@ By default, Gitea doesn't include a `robots.txt` file.
My Gitea robots.txt is available [here](
{% include_relative modules/gitea-robots.txt/ %}
## Building
### Build-era dependencies
* [golang]( (on stretch, use [version in stretch-backports](, as gitea requires version 1.11 or higher)
* [make](
* [go-bindata](
Also, make sure to configure [GOPATH]( for your user.
On Bash, run:
echo "export GOPATH=$HOME/go" >> ~/.bash_profile
# load (source) ~/.bash_profile
source ~/.bash_profile
Download Gitea source code by running:
go get -d -u
It should take at maximum few minutes.
Then, move to Gitea source code folder:
cd "$GOPATH/src/"
List releases with `git tag -l`.
At the time of writing, the latest stable version is `v1.8.3`.
Choose it by running:
git checkout v1.8.3
With `git branch -a`, you can see you switched to the release.
$ git branch -a
* (HEAD detached at v1.8.3)
Start the build by running:
<!-- TODO: bindata is not recommended here: -->
TAGS="bindata" make generate build
After build, you can try the binary by running:
./gitea web
If it runs without errors, close it by Ctrl+C.
Copy the binary to `/usr/local/bin/gitea` by running:
sudo cp $GOPATH/src/ /usr/local/bin/gitea
## Installation
### Dependencies
* [git](
* [nginx](
* [mariadb-server]( (optional to be installed on the same server)
First, make sure Git is installed on your server. You can try this by running:
git --version
Then, create user for Gitea:
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
After creating user account successfully, create folders:
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
### `systemd` service
First, download template by running:
curl -L | sudo tee /etc/systemd/system/gitea.service > /dev/null
If your MySQL server runs on the same server, edit the file by running `sudo -e /etc/systemd/system/gitea.service`.
Uncomment the following line:
Then, start the service by running:
sudo systemctl daemon-reload
sudo systemctl enable --now gitea
To see if Gitea runs successfully, run:
curl -I
It should return `HTTP/1.1 200 OK`.
### Nginx configuration
Filename `/etc/nginx/sites-available/gitea`:
upstream gitea {
server {
# see and for listen, SSL configuration, etc.
# ...
# ...
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://gitea;
location = /robots.txt {
root /var/www/gitea-robots.txt;
To get `robots.txt` to work, do steps listed [here](#robotstxt).
For more Nginx configuration, see [certbot]( and [nginx](
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/
sudo systemctl restart nginx
After that, open `` in your browser.
Tutorial is going to be continued with MySQL configuration, email server setup, etc.
### Set permissions after running the Web installer
chmod 750 /etc/gitea
chmod 644 /etc/gitea/app.ini
## Update script
Tip: Subscribe to Gitea repository update notifications on [UpdateWatch](
Make sure your `$GOPATH` is [correctly set](
cd $GOPATH/src/
git pull
echo "Select version"
echo "git checkout vX.X.X && exit"
echo ""
echo ""
git tag -l
# bindata is not recommended here:
TAGS="bindata" make generate build
sudo systemctl stop gitea
sudo cp $GOPATH/src/ /usr/local/bin/gitea
sudo systemctl daemon-reload
sudo systemctl start gitea
\ No newline at end of file
gitea-robots.txt @ 2c881fa8
Subproject commit 37d3238224c72630a3a20c9600a5e5e1dc78714b
Subproject commit 2c881fa8028cd02a4b975435680399341857010d
......@@ -5,6 +5,8 @@ permalink: /nginx
Most of the configuration can be found from [Certbot]( page.
If you use Haproxy, see [Nginx backends on Haproxy](
## Useragent Blocklist
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment