This tutorial will guide you through the process of installing Gogs, a self-hosted Git service written in Go programming language, on OpenBSD.
Before we start, make sure that you have the following:
Before installing Gogs, we need to install some dependencies. Open a terminal and run the following command to install Git, PostgreSQL, and Go:
$ doas pkg_add git postgresql go
Gogs requires a PostgreSQL database. Let's create a new database and user for Gogs:
Log in to the postgresql
user account by running the following command:
$ doas su - _postgresql
Create a new database and user by running the following SQL commands:
$ createdb gogs
$ createuser --encrypted --pwprompt gogs
When prompted for a password, enter a secure password and remember it since we'll need it later.
Grant the newly created user access to the gogs
database:
$ psql
# GRANT ALL PRIVILEGES ON DATABASE gogs TO gogs;
# \q
This will grant full privileges to the user gogs
on the gogs
database.
Exit from the postgresql
user account:
# exit
Download the latest version of Gogs from the official website by running the following command in the terminal:
$ wget https://cdn.gogs.io/gogs_v0.12.3_openbsd_amd64.tar.gz
Extract the downloaded file:
$ tar -xzf gogs_v0.12.3_openbsd_amd64.tar.gz
Move the extracted files to your preferred location. For example, let's move it to /home/gogs/
:
$ mv gogs/ /home/gogs/
Change the directory to the gogs
folder:
$ cd /home/gogs/gogs/
Create a new app.ini
file to configure the Gogs settings:
$ cp conf/app.ini.sample conf/app.ini
Open the app.ini
file using your favorite text editor. For example, we'll use vi
:
$ vi conf/app.ini
Edit the following sections to match your settings:
[database]: Modify the URL, username, and password to match the PostgreSQL database settings you created earlier. For example:
[database]
DB_TYPE = postgres
HOST = localhost:5432
NAME = gogs
USER = gogs
PASSWD = mysecretpassword
SSL_MODE = disable
PATH =
[security]: Modify the SECRET_KEY
value to a secure and random string. For example:
[security]
INSTALL_LOCK = true
SECRET_KEY = 53ubx0rk7g8no37ptys2wv61m5649ijhefdchlazqm
INTERNAL_TOKEN = X578GBpxiiojsaM0MJBjShcIFZonOPaA
Save and close the app.ini
file.
Change the owner of the gogs
directory to the www
user:
$ doas chown -R www:www /home/gogs/gogs/
This is required to allow Gogs to bind to the network port.
Start the Gogs service by running the following command in the terminal:
$ ./gogs web
If everything goes well, you should see the following message in the terminal:
[Macaron] listening on :3000 (http)
[Macaron] listening on :2222 (ssh)
This means that Gogs is running and accessible at http://localhost:3000
and ssh://localhost:2222
.
Open your web browser and visit http://localhost:3000
to access the Gogs installation wizard.
Follow the wizard to complete the installation process.
Congratulations! You have successfully installed Gogs on OpenBSD.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!