Gogs is an open source version control platform similar to Github. It is 100% open source and free of charge. All source code is available under the MIT License on Github. It is robust, scalable and a great alternative to other git services.
Gogs has rich features like issues and time tracking, repository branching, file locking and tagging, merging and many others features that you will find in a typical source control platform.
Gogs streamlines your collaborative workflows. Visualize, prioritize, coordinate, and track your progress your way with Gogs’ flexible project management tools.
This brief tutorial is going to show students and new users how to easily install Gogs on Ubuntu 16.04 and 18.04.
To install Gogs on Ubuntu, follow the steps below
Step 1: Install Git and Create Git User
Before continue below, run the command to install git package on Ubuntu.
sudo apt update sudo apt install git
After installing Git, run the commands below to create a Git user to run Gogs services. To do that run the commands below
sudo adduser --system --group --disabled-password --shell /bin/bash --home /home/git --gecos 'Git Version Control' git
You should see similar message as below:
Output: Adding system user `git' (UID 122) . Adding new group `git' (GID 127) . Adding new user `git' (UID 122) with group `git' . Creating home directory `/home/git' .
Next, continue below and install MariaDB
Step 2: Install MariaDB
Gogs requires a database server to store it content. and MariaDB is a great place to start with looking for an open source database server.
To install MariaDB run the commands below.
sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
Run these on Ubuntu 16.04 LTS
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
Run these on Ubuntu 17.10 and 18.04 LTS
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
Now that you’ve installed all the packages that are required for Gogs to function, continue below to start configuring the servers. First run the commands below to create a blank Gogs database and database user.
To logon to MariaDB database server, run the commands below.
sudo mysql -u root -p
Change the GLOBAL innodeb_file_per_table to On.
SET GLOBAL innodb_file_per_table = ON;
Then create a database called gogsdb
CREATE DATABASE gogsdb;
Create a database user called gogsuser with new password
CREATE USER 'gogsuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON gogsdb.* TO 'gogsuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
Next, run the commands below to update the database character set.
ALTER DATABASE gogsdb CHARACTER SET = utf8mb4 COLLATE utf8mb4_unicode_ci;
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Next, run the commands below to open MariaDB default config file.
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Then add the lines below and save.
innodb_file_format = Barracuda innodb_large_prefix = 1 innodb_default_row_format = dynamic
Restart MariaDB / MySQL after that.
sudo systemctl restart mariadb.service sudo systemctl restart mysql.service
Step 3: Install Gogs Packages
After creating the user account above, run the commands below to download Gogs latest package. You can find its latest version from the link below:
Run the commands below to download:
cd /tmp wget /download/v0.11.66/linux_amd64.tar.gz
Then extract the downloaded file into the Git user’s home directory created above by running the commands below:
sudo tar xvf linux_amd64.tar.gz -C /home/git
After that, give the Git user ownership of the Gogs folder.
sudo chown -R git: /home/git/gogs
Next, create Gogs service scripts by copying it from the user directory into the systemd directory.
sudo cp /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/
After that, reload systemd and start gogs service
sudo systemctl daemon-reload sudo systemctl enable gogs sudo systemctl start gogs
To check Gogs’ status, run the commands below:
sudo systemctl status gogs
You should see similar message as below:
● gogs.service - Gogs Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: ena Active: active (running) since Fri 2019-04-26 09:58:25 CDT; 4s ago Main PID: 7189 (gogs) Tasks: 5 (limit: 4683) CGroup: /system.slice/gogs.service └─7189 /home/git/gogs/gogs web Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ WARN] Custom config Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [TRACE] Custom path: Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [TRACE] Log path: /ho Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [TRACE] Log Mode: Con Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] Gogs 0.11.66. Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] Cache Service Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] Session Servi Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] SQLite3 Suppo Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] Run Mode: Dev Apr 26 09:58:25 ubuntu1804 gogs: 2019/04/26 09:58:25 [ INFO] Listen: http:
Next, open your browser and browse to the server hostname or IP address followed by port 3000
Type in the database connection info and continue with the setup.
Setup other settings
Setup your admin account and Install
After the installation, you should be able to logon and use Gogs as a git service.
Congratulations! You have successfully installed and configured Gogs Git service on Ubuntu 16.04 | 18.04 LTS
You may also like the post below: