<\/span><\/h2>\nGitea uses SQLite, MySQL\/MariaDB, and PostgreSQL to store its data. Here, we will use MariaDB for our database solution.<\/p>\n
Let’s install MariaDB by running the following command:<\/p>\n
apt-get install mariadb-server mariadb-client -y<\/pre>\nOnce installed, run the following command to secure the MariaDB installation:<\/p>\n
mysql_secure_installation<\/pre>\nThis command will set the root password, remove anonymous users, disallow root login remotely and remove the test database as shown below:<\/p>\n
Enter current password for root (enter for none): press [Enter]\nSet root password? [Y\/n]: N\nRemove anonymous users? [Y\/n]: Y\nDisallow root login remotely? [Y\/n]: Y\nRemove test database and access to it? [Y\/n]: Y\nReload privilege tables now? [Y\/n]: Y<\/pre>\nOnce MariaDB is secured, log in to MariaDB shell with the following command:<\/p>\n
mysql -u root -p<\/pre>\nEnter your root password when prompt then change the GLOBAL innodeb_file_per_table<\/code> to On<\/code>:<\/p>\nMariaDB [(none)]> SET GLOBAL innodb_file_per_table = ON;<\/pre>\nNext, create a database and user for Gitea with the following command:<\/p>\n
MariaDB [(none)]> CREATE DATABASE gitea;\nMariaDB [(none)]> CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'password<\/span>';<\/pre>\nMake sure to choose a unique and strong password for your Gitea MariaDB user.<\/p>\n
Next, grant all the privileges to Gitea and alter the database with the following command:<\/p>\n
MariaDB [(none)]> GRANT ALL ON gitea.* TO 'gitea'@'localhost' IDENTIFIED BY 'password<\/span>' WITH GRANT OPTION;\nMariaDB [(none)]> ALTER DATABASE gitea CHARACTER SET = utf8mb4 COLLATE utf8mb4_unicode_ci;<\/pre>\nFinally, flush the privileges and exit from the MariaDB shell with the following command:<\/p>\n
MariaDB [(none)]> FLUSH PRIVILEGES;\nMariaDB [(none)]> EXIT;<\/pre>\nNext, open the MariaDB default configuration file and tweak some settings:<\/p>\n
nano \/etc\/mysql\/mariadb.conf.d\/50-server.cnf<\/pre>\nAdd the following lines:<\/p>\n
innodb_file_format = Barracuda\ninnodb_large_prefix = 1\ninnodb_default_row_format = dynamic<\/pre>\nSave and close the file. Then, restart the MariaDB service to apply the configuration changes:<\/p>\n
systemctl restart mariadb<\/pre>\n<\/span>Step 3: Download and Install Gitea on Debian 9<\/span><\/h2>\nGo to the Gitea download page and download the latest version of the Gitea binary package with the following command:<\/p>\n
wget https:\/\/github.com\/go-gitea\/gitea\/releases\/download\/v1.9.1\/gitea-1.9.1-linux-amd64<\/pre>\nOnce downloaded, copy the downloaded binary to the \/usr\/local\/bin<\/code> directory:<\/p>\ncp gitea-1.9.1-linux-amd64 \/usr\/local\/bin\/gitea<\/pre>\nNext, provide executable permission using the following command:<\/p>\n
chmod 755 \/usr\/local\/bin\/gitea<\/pre>\nYou can now check the Gitea version using the following command:<\/p>\n
gitea --version<\/pre>\nYou should get the following output:<\/p>\n
Gitea version 1.9.1 built with GNU Make 4.1, go1.12.8 : bindata, sqlite, sqlite_unlock_notify<\/pre>\nNext, we will need to create a directory structure for our repositories, configuration and log files. Run the following command to create the directory structure for Gitea:<\/p>\n
mkdir -p \/etc\/gitea \/var\/lib\/gitea\/{custom,data,indexers,public,log}<\/pre>\n