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 postgresqlStart sql session.
sudo su postgres
psqlCreate user and database.
CREATE USER gitea WITH PASSWORD '<password>';
CREATE DATABASE gitea OWNER gitea;
# exit postgres.
\qWe will make a few tweaks to postgres config.
Open the conf file.
sudo nano /etc/postgresql/10/main/postgresql.confSet 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= 4MBRestart db.
sudo service postgresql restartNext, 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
exitThe 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 webNext a service needs to be created to keep Gitea running, and restart it when the server restarts.
sudo nano /etc/systemd/system/gitea.serviceEnter 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.targetEnable and start the service.
sudo systemctl enable gitea.service
sudo systemctl start gitea.serviceInstall.
sudo apt install nginxCreate the Nginx site.
sudo nano /etc/nginx/sites-enabled/giteaEnter 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 reloadChange 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 restartNow 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/
