<\/span><\/h2>\n\n\n\nNginx web server can be installed with the following command:<\/p>\n\n\n\n
sudo apt install nginx -y<\/pre>\n\n\n\nOnce, the installation is complete you can check the status of the Nginx service:<\/p>\n\n\n\n
sudo systemctl status nginx<\/pre>\n\n\n\n<\/span>Step 4. Install MariaDB database server<\/span><\/h2>\n\n\n\nMariaDB is used as database backend for the Gitea and it can be installed with the command below:<\/p>\n\n\n\n
sudo apt-get install mariadb-server -y<\/pre>\n\n\n\n<\/span>Step 5. Configure MariaDB database server<\/span><\/h2>\n\n\n\nOnce, the database server is installed successfully we need to configure it.<\/p>\n\n\n\n
Log in to the MariaDB shell with “mysql<\/b>” command and enable the Innodb table:<\/p>\n\n\n\nMariaDB [(none)]> SET GLOBAL innodb_file_per_table = ON;<\/pre>\n\n\n\nExit from the MariaDB shell with “exit<\/b>” command and open the default MariaDB configuration file:<\/p>\n\n\n\nsudo nano \/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/pre>\n\n\n\nAdd the following lines of code under the “mysqld<\/b>” section<\/p>\n\n\n\ninnodb_file_format = Barracuda
\ninnodb_large_prefix = 1
\ninnodb_default_row_format = dynamic<\/pre>\n\n\n\nOnce, the changes are made restart the MariaDB service in order for the changes to take effectivity.<\/p>\n\n\n\n
sudo systemctl restart mariadb<\/pre>\n\n\n\n<\/span>Step 6. Create database and database user<\/span><\/h2>\n\n\n\nGitea software requires database and user in order can function properly. To create them and grant the proper privileges please log in back to the MariaDB shell and execute the following commands:<\/p>\n\n\n\n
MariaDB [(none)]>CREATE DATABASE gitea;
MariaDB [(none)]>CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'strongpasswordhere';
MariaDB [(none)]>GRANT ALL ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'strongpasswordhere' WITH GRANT OPTION;
MariaDB [(none)]>ALTER DATABASE gitea CHARACTER SET = utf8mb4 COLLATE utf8mb4_unicode_ci;
MariaDB [(none)]>FLUSH PRIVILEGES;
MariaDB [(none)]>exit;<\/pre>\n\n\n\n<\/span>Step 7. Install Gitea<\/span><\/h2>\n\n\n\nThis is the step we were waiting so long and that is installing the Gitea software. Before we install it, we need to create a system user to run Gitea with the following command:<\/p>\n\n\n\n
sudo adduser --system --group --disabled-password --shell \/bin\/bash --home \/home\/git --gecos 'Git Version Control' git<\/pre>\n\n\n\nNext is to download the latest version of Gitea on your server.<\/p>\n\n\n\n
sudo wget https:\/\/dl.gitea.io\/gitea\/1.14.6\/gitea-1.14.6-linux-amd64<\/pre>\n\n\n\nOnce, the Gitea is downloaded we need to copy the binary to the system path and set the right permissions :<\/p>\n\n\n\n
sudo cp gitea-1.14.6-linux-amd64 \/usr\/bin\/gitea && chmod 755 \/usr\/bin\/gitea<\/pre>\n\n\n\nNext, step is to create Gitea directory for storing the data and the logs along with their permissions:<\/p>\n\n\n\n
sudo mkdir -p \/etc\/gitea \/var\/lib\/gitea\/{custom,data,indexers,public,log}
sudo chown git:git \/etc\/gitea \/var\/lib\/gitea\/{custom,data,indexers,public,log}
sudo chmod 750 \/var\/lib\/gitea\/{data,indexers,log}
sudo chmod 770 \/etc\/gitea<\/pre>\n\n\n\n<\/span>Step 8. Create Gitea Service<\/span><\/h2>\n\n\n\nCreate an empty file:<\/p>\n\n\n\n
sudo nano \/etc\/systemd\/system\/gitea.service<\/pre>\n\n\n\nAnd, import the following lines of code:<\/p>\n\n\n\n
[Unit]
Description=Gitea
After=syslog.target
After=network.target
After=mysql.service
[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=\/var\/lib\/gitea\/
ExecStart=\/usr\/bin\/gitea web -c \/etc\/gitea\/app.ini
Restart=always
Environment=USER=git HOME=\/home\/git GITEA_WORK_DIR=\/var\/lib\/gitea
[Install]
WantedBy=multi-user.target<\/pre>\n\n\n\nAfter creating the file with content in it reload the configuration file, enable and start the Gitea service.<\/p>\n\n\n\n
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea<\/pre>\n\n\n\nTo check if Gitea is running properly execute the following command:<\/p>\n\n\n\n
sudo systemctl status gitea<\/pre>\n\n\n\nThe output should be similar to this:<\/p>\n\n\n\n
# sudo systemctl status gitea
\n\u25cf gitea.service - Gitea<\/pre>\n\n\n\nLoaded: loaded (\/etc\/systemd\/system\/gitea.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-09 23:36:36 CEST; 8min ago
Main PID: 42187 (gitea)
Tasks: 6 (limit: 4652)
Memory: 111.8M
CGroup: \/system.slice\/gitea.service
\u2514\u250042187 \/usr\/bin\/gitea web -c \/etc\/gitea\/app.ini<\/p>\n\n\n\n