By default, Gitea doesn’t include a robots.txt file.

My Gitea robots.txt is available here.


sudo mkdir -p /var/www/gitea-robots.txt/
sudo chown -R $USER:$USER /var/www/gitea-robots.txt/
git clone /var/www/gitea-robots.txt/

Add a cronjob

30	6	*/3	*	*	cd /var/www/gitea-robots.txt/ && git pull --quiet


location = /robots.txt {
        root /var/www/gitea-robots.txt;


Build-time dependencies

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:

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



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.

For more Nginx configuration, see certbot and nginx.

Enable Nginx configuration

sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/gitea /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.

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