Special thanks to Bryan Gilbert, whose tutorial this write up is based on.
Login to the server. In this case we are using Ubuntu 18.
Create a user account βgitβ which will be used by gitea. There will be no password, but will have a home directory.
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
Install postgresql.
sudo apt install postgresql
Start sql session.
sudo su postgres
psql
Create user and database.
CREATE USER gitea WITH PASSWORD '<password>';
CREATE DATABASE gitea OWNER gitea;
# exit postgres.
\q
We will make a few tweaks to postgres config.
Open the conf file.
sudo nano /etc/postgresql/10/main/postgresql.conf
Set shared_buffers to 25% of total ram. Example: with 4gb ram:
shared_buffers= 1024MB
# other settings:
max_connections= 500
track_counts= on
autovacuum= on
work_mem= 4MB
Restart db.
sudo service postgresql restart
Next, we can install Gitea. You can get the current version number from gitea.
# change user to git
sudo su git
# make gitea directory
cd /home/git && mkdir gitea && cd gitea
# copy in the latest version of gitea
wget -O gitea https://dl.gitea.io/gitea/1.8.2/gitea-1.8.2-linux-amd64
# change permissions
chmod +x gitea
# exit git account
exit
The Gitea server can be run manually for testing if needed. The installation can be finished at this point as well, but we will wait until Nginx is running first.
./gitea web
Next a service needs to be created to keep Gitea running, and restart it when the server restarts.
sudo nano /etc/systemd/system/gitea.service
Enter the service information.
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
After=postgresql.service
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gitea
ExecStart=/home/git/gitea/gitea web
Restart=always
Environment=USER=git HOME=/home/git
[Install]
WantedBy=multi-user.target
Enable and start the service.
sudo systemctl enable gitea.service
sudo systemctl start gitea.service
Install.
sudo apt install nginx
Create the Nginx site.
sudo nano /etc/nginx/sites-enabled/gitea
Enter server information.
server {
listen 80;
server_name <your-domain or IP address>;
location / {
proxy_pass http://localhost:3000;
}
proxy_set_header X-Real-IP $remote_addr;
}
Finally, remove the default Nginx site and reload Nginx.
sudo rm /etc/nginx/sites-enabled/default
sudo service nginx reload
Change the upload limit size in Nginx.
sudo nano /etc/nginx/nginx.conf
# change this line to the size you need. If line is not there, add to the http {} section.
client_max_body_size = 100M;
Restart Nginx.
service nginx restart
Now you can navigate to the website and complete installation. You will need to enter the db password, etc.
https://docs.gitea.io/en-us/customizing-gitea/