Installing Gitea on Kali Linux
In this tutorial, we will cover the steps to install Gitea on Kali Linux. Gitea is a self-hosted Git service with a focus on simplicity, security, and speed.
Prerequisites
Before we start installing Gitea, we need to make sure we have the following prerequisites:
- Kali Linux latest version
- sudo privileges
- Git
- MySQL or PostgreSQL (for storing the database)
Step 1: Download Gitea
To download Gitea, we first need to get the latest version of Gitea from the official website: https://gitea.io
Once the download is complete, extract the contents of the archive with the following command:
tar -zxvf gitea-1.x.x-linux-amd64.tar.gz
Replace 1.x.x with the latest version number.
Step 2: Configure the Database
Before we run Gitea, we need to configure the database. Choose either MySQL or PostgreSQL and install the required packages using the following commands:
For MySQL:
sudo apt-get update
sudo apt-get install mysql-server mysql-client
For PostgreSQL:
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Step 3: Create Database and User
Once the database is installed, we need to create a new database for Gitea and a new user to access that database.
Log in to MySQL or PostgreSQL using the following commands:
For MySQL:
mysql -u root -p
For PostgreSQL:
sudo su - postgres
psql
Once you are logged in to the database, create a new database and user with the following commands:
For MySQL:
CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea'@'localhost';
Replace password with your desired password.
For PostgreSQL:
CREATE DATABASE gitea;
CREATE USER gitea WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE gitea TO gitea;
Replace password with your desired password.
Step 4: Configure Gitea
Next, we need to configure Gitea. Navigate to the extracted Gitea directory and create a new configuration file using the following command:
cp custom/conf/app.ini.sample custom/conf/app.ini
Open the app.ini file using a text editor and update the following settings:
APP_NAME = Gitea
RUN_MODE = prod
[database]
DB_TYPE = mysql or postgres
HOST = 127.0.0.1:3306
NAME = gitea
USER = gitea
PASSWD = password
SSL_MODE = disable
Replace mysql or postgres with the database type you are using, 127.0.0.1:3306 with the database host and port number, gitea with the database name, gitea with the database user, and password with the password you set for the database user.
Step 5: Create a Systemd Service
To run Gitea as a service, we need to create a Systemd service. Create a new file with the following command:
sudo nano /etc/systemd/system/gitea.service
Copy and paste the following code into the file:
[Unit]
Description=gitea
After=syslog.target
After=network.target mysqld.service
[Service]
Type=simple
User=root
WorkingDirectory=/path/to/gitea
ExecStart=/path/to/gitea gitea web
Restart=always
[Install]
WantedBy=multi-user.target
Replace /path/to/gitea with the actual path where your Gitea files are located.
Save and exit the file.
Step 6: Start the Service
Reload the Systemd daemon and start the Gitea service with the following commands:
sudo systemctl daemon-reload
sudo systemctl start gitea
sudo systemctl enable gitea
You can now access Gitea by going to http://localhost:3000 in your web browser.
Conclusion
In this tutorial, we learned how to install Gitea on Kali Linux. Now you can enjoy the simplicity, security, and speed of a self-hosted Git service.