How to install Pagure on Debian Latest?
Pagure is a self-hosted Git management software which provides Git repository hosting with features like branches, pull requests and issues management through a web interface. In this tutorial, we will cover how to install Pagure on Debian Latest.
System Requirements
Before you start installing Pagure, you need to meet the following requirements:
- Debian server running the latest version
- Root access or sudo privileges
- A web server (Apache, Nginx)
- Python 3.5 or later
- Virtualenv
- Git
Step 1: Install Required Packages
First, we need to update the package list and then install some packages which are required for Pagure installation. Open the terminal and run the following commands:
sudo apt update
sudo apt install python3-dev python3-virtualenv virtualenv python3-pip python3-setuptools python3-wheel git libssl-dev libffi-dev libjpeg-dev libpng-dev zlib1g-dev libpq-dev postgresql
Step 2: Create a Python Virtual Environment
Next, we will create a Python Virtual Environment to install Pagure and its dependencies.
To create a virtual environment, run the following command:
virtualenv -p python3 ~/pagure
Activate the environment with the following command:
source ~/pagure/bin/activate
Step 3: Install Pagure
Now, we can install Pagure and its dependencies using pip. Run the following command to install Pagure:
pip install pagure[mysql] # If you want to use MySQL
or
pip install pagure[psql] # If you want to use PostgreSQL
Step 4: Configure Pagure
After installing Pagure, we need to configure it. By default, Pagure uses the SQLite database. However, it is recommended to use PostgreSQL or MySQL for better performance.
Let's create a configuration file using the following command:
cp ~/pagure/share/pagure/pagure.cfg ~/pagure/etc/pagure.cfg
Next, open the configuration file with a text editor:
nano ~/pagure/etc/pagure.cfg
Find the following lines:
## Database backend. Sqlite3 or mysql.
;database_backend=sqlite
#database_backend=mysql
Uncomment the second line and comment out the first line:
#database_backend=sqlite
database_backend=postgresql
In the same file, find the following lines:
## Database connection string. Used by the sqlalchemy.
#sql_uri=sqlite:///pagure.db
sql_uri=sqlite:///pagure.sqlite
Comment out the first line and uncomment the second line:
sql_uri = postgresql://pagure:[email protected]/pagure
# sql_uri=sqlite:///pagure.sqlite
Set your PostgreSQL database connection string.
Save and close the file.
Step 5: Create a Database
Next, we need to create a database for Pagure.
If you are using PostgreSQL, log in to the postgres user with the following command:
sudo su postgres
You can now create a new PostgreSQL database with the following command:
createdb -O pagure -E utf8 pagure
If you are using MySQL, log in to the MySQL console and create a new database:
mysql -u root -p
CREATE DATABASE pagure_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'pagure_user'@'localhost' IDENTIFIED BY 'pagure_password';
GRANT ALL PRIVILEGES ON pagure_db.* TO 'pagure_user'@'localhost';
FLUSH PRIVILEGES;
quit
Replace pagure_db, pagure_user and pagure_password with your own values.
Step 6: Create a Pagure User
Next, we need to create a new user for Pagure:
pagure-admin user -c ~/pagure/etc/pagure.cfg create --name "Pagure User" --password "changeme" --email "[email protected]"
Step 7: Create and Run a Systemd Service
Now we need to create a systemd service so that our Pagure server starts automatically at boot.
Let's create a file named pagure.service with the following command:
sudo nano /etc/systemd/system/pagure.service
Add the following content to the file:
[Unit]
Description=Pagure Git Management Software
After=network.target postgresql.service
[Service]
User=root
Group=root
WorkingDirectory=/opt/pagure/
ExecStart=/opt/pagure/bin/pagure --config /opt/pagure/etc/pagure.cfg
Restart=always
[Install]
WantedBy=multi-user.target
Save and close the file.
Now start the service:
sudo systemctl start pagure
sudo systemctl enable pagure
You can check the status of the service with this command:
sudo systemctl status pagure
Step 8: Configure the Firewall
Lastly, we need to configure the firewall to allow traffic to Pagure.
sudo ufw allow http
sudo ufw allow https
sudo ufw allow ssh
sudo ufw reload
Congratulations! You have successfully installed Pagure on Debian Latest. You can now access your Pagure installation by using your web browser to visit http://<your-server-ip>:5000 or https://<your-server-ip>:5000.