This guide will walk you through the process of installing Gogs on a Debian 9 VPS with MariaDB as a database server.
Gogs is a free and open-source self-hosted Git service written in the Go programming language. It’s easy-to-install, cross-platform, and lightweight, and all of these attributes allow for Gogs to run on all sorts of hardware easily. This guide should work on other Linux VPS systems as well, but it was tested and written for a Debian 9 VPS. Let’s begin with the installation.
Table of Contents
Prerequisites
- A Debian 9 Virtual Server
- A user account with sudo privileges, or access to the ‘root’ user itself
Step 1: Install Required packages
Log in to your VPS via SSH as root or as a sudo user:
Make sure you replace “IP_Address” and “Port_Number” to your server’s respective IP address and SSH port numbers.
Once logged in, issue the following commands to update all installed packages to their latest available versions:
Afterwards, install the git package using the following command:
Step 2: Create a MariaDB Database
Gogs can use MySQL/MariaDB, PostgreSQL, MSSQL, TiDB and SQLite3 for its database backend.
In this tutorial, we will use MariaDB. If the MySQL or MariaDB server is not installed on your server, you can install the latest MariaDB version by executing the following command:
When the MariaDB installation is complete, it is recommended to run the mysql_secure_installation
script to improve the security of your database server:
Answer the security questions as follows. If at any point you are asked for the root MariaDB password before proceeding, just press the [Enter] key, as no password is set by default:
Log in to the MySQL shell using the MySQL root user and the password that you have previously set up:
Create a MySQL database and user for Gogs, and grant permissions to the user by issuing the following commands:
Make sure you replace ‘strongpassword‘ with an actual strong password.
Step 3: Install Gogs
Create a new system user that will run the Gogs server:
Next, download the Gogs binary from the Gogs Github page using ‘wget’:
Extract the downloaded archive to the /opt/gogs
directory:
Change the ownership of the directory to the Gogs user:
Next, copy the SystemD unit file. This allows us to create a SystemD service for Gogs:
Open the unit file using your text editor of choice. We’ll use nano.
Once the file is open, edit it as follows:
Once you’re done editing the file, save it, then start and enable the Gogs service:
Run the following command to verify that the Gogs service is started successfully:
Step 4: Set Up Gogs
Once the installation is complete, go to http://server_ip:3000/install
and fill in all of the required fields. Do not forget to replace “server_ip” with your server’s public IP address:
Database Settings
- Database Type: MySQL
- Host:
127.0.0.1:3306
- User: gogs
- Password: strongpassword
- Database Name: gogs
General Settings of Gogs
- Application Name: Gogs
- Repository Root Path:
/opt/gogs/gogs-repositories
- Run User: gogs
- Domain: SERVER_IP
- SSH Port: 22
- HTTP Port: 3000
- Application URL: http://SERVER_IP:3000/
- Log Path:
/opt/gogs/log
Once done, click on the install button and you’re good to go.
Administrative access is automatically granted to the first registered user:
That’s it. You have successfully installed Gogs on your Debian 9 VPS. For more information about how to manage your Gogs installation, please refer to the official Gogs documentation.
Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to set up everything and install Gogs for you. They are available 24/7 and will take care of your request immediately.
PS. If you liked this post or found it helpful, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment down in the comments section. Thank you.