Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to install Gogs on Ubuntu 16.04

In this guide, we will explain how to Install Gogs on an Ubuntu 16.04 Virtual Server with MariaDB and Apache2 as proxy server. Gogs is an open source self-hosted Git service written in the Go programming language. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 16.04 VPS.

First of all login to your Ubuntu 16.04 VPS via SSH as user root

ssh root@IP_address

At the very beginning, it is best to start a screen session by executing the following command

screen -U -S gogs

Update the OS packages on your virtual server using the following commands:

apt-get update && apt-get -y upgrade
apt-get install software-properties-common nano git wget apt-transport-https

Make sure to always keep your server up to date.

Install MariaDB 10.1

To add the MariaDB repository to your sources list and install the latest MariaDB server, run the following commands:

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu xenial main'

Once the key is imported and the repository added you can install MariaDB with:

apt-get update && apt-get -y upgrade
apt-get install mariadb-server

Next, we need to create a database for our Gogs installation.

mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE gogs;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' IDENTIFIED BY 'your_gogs_password';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q

Install Apache web server on your Ubuntu VPS executing the following command:

apt-get install apache2

Install PHP and required PHP modules

To install the latest stable version of PHP version 7 and all necessary modules, run:

apt-get install python-software-properties
apt-get install python-software-properties
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y php7.1 libapache2-mod-php7.1 php7.1-mbstring php7.1-curl php7.1-zip php7.1-gd php7.1-mysql php7.1-mcrypt

Enable the Apache2 proxy module if it is not already done:

a2enmod proxy proxy_http

In order to activate the new configuration, restart the Apache web server using the following command:

service apache2 restart

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘gogs.conf’ on your virtual server:

touch /etc/apache2/sites-available/gogs.conf
ln -s /etc/apache2/sites-available/gogs.conf /etc/apache2/sites-enabled/gogs.conf
nano /etc/apache2/sites-available/gogs.conf

Then, add the following lines:


ServerAdmin [email protected]
DocumentRoot /var/www/html/gogs/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ProxyRequests Off
ProxyPass / http://1.2.3.4:3000/
ProxyPassReverse / http://1.2.3.4:3000/
ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common

Do not forget to replace 1.2.3.4 with your actual server IP address and your-domain.com with your domain name.

Restart the Apache web server for the changes to take effect:

service apache2 restart

Install Gogs

Download and extract the latest version of Gogs on your server:

cd /opt && wget https://dl.gogs.io/0.11.4/linux_amd64.zip
[user]$ sudo unzip linux_amd64.zip
[user]$ sudo mv gogs/ /var/www/html/gogs

cd into the directory just created:

cd /var/www/html/gogs

and execute the following command:

./gogs web &

Setup Gogs

Open your favorite web browser, navigate to http://your-domain.com/install and if you configured everything correctly the Gogs installer should be starting. You should follow the easy instructions on the install screen inserting the necessary information as requested.

Database Settings
– Database Type: MySQL
– Host: 127.0.0.1:3306
– User: gogs
– Password: your_gogs_password
– Database Name: gogs

General Settings of Gogs
– Application Name: Gogs: Go Git Service
– Repository Root Path: /home/git/gogs-repositories
– Run User: root
– Domain: your-domain.com
– SSH Port: 22
– HTTP Port: 3000
– Application URL: http://your-domain.com/

Finally, click Install Gogs 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 Ubuntu 16.04 VPS. For more information about how to manage your Gogs installation, please refer to the official Gogs documentation.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.



This post first appeared on Virtual-Server.org Virtual Server, please read the originial post: here

Share the post

How to install Gogs on Ubuntu 16.04

×

Subscribe to Virtual-server.org Virtual Server

Get updates delivered right to your inbox!

Thank you for your subscription

×