How to Install Gogs on Ubuntu 18.04 Bionic Beaver

Install Gogs on Ubuntu 18.04 Bionic Beaver

In this article, we will have explained the necessary steps to install and configure Gogs on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Gogs is an open source version control platform similar to Github. It’s lightweight, cross-platform, and easy to install, so you can easily set up a self-hosted git service in your development environment. Gogs is distributed as an independent binary distribution and has minimal requirements so it can run on all platforms that Go supports, such as Windows, Linux, ARM, Mac, etc.

Install Gogs on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install and Configure MariaDB.

Gogs can use MariaDB, PostgreSQL, MSSQL, TiDB and SQLite3 databases for its database backend. In this tutorial, we will use MariaDB. Install the latest MySQL server by executing the following command:

When the MariaDB installation is complete, secure your MariaDB installation using the mysql_secure_installation script:

Install Gogs on Ubuntu 18.04

Log in to the MySQL console with the MySQL root user, using the password that you have set up in the previous step:

Create a MySQL database and user for Gogs, and grant permissions to the user using the following commands:

Step 3. Install Gogs.

First, create a new system user for Gogs:

The following commands will download the Gogs binary from the Gogs Github page:

Extract the archive to the /opt/gogs directory:

Change the ownership of the directory to the Gogs user:

Next, copy the systemd unit file:

Open the unit file using your favorite text editor:

Once the file is open, edit it as follows:

Save and close the file, then start and enable the Gogs service:

Step 4. Install Gogs using the web installer.

Now that Gogs is downloaded and running, it is time to finalize the installation through the web interface. Open your browser, type http://YOUR_DOMAIN_IR_IP:3000 and fill in all of the required fields. Remember to replace “server_ip” with your server’s public IP address:

Database Settings
– Database Type: MySQL
– Host:
– 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

Finally, click install and you’re good to go.

That’s all you need to do to install Gogs on Ubuntu 18.04 Bionic Beaver. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.