How to Install Gogs on OpenBSD
This tutorial will guide you through the process of installing Gogs, a self-hosted Git service written in Go programming language, on OpenBSD.
Prerequisites
Before we start, make sure that you have the following:
- OpenBSD operating system installed and updated to the latest version
- Root access or a user account with sudo privileges
- Basic knowledge of the command line interface (CLI)
Step 1: Install Gogs Dependencies
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
Step 2: Create a PostgreSQL Database
Gogs requires a PostgreSQL database. Let's create a new database and user for Gogs:
Log in to the
postgresqluser account by running the following command:$ doas su - _postgresqlCreate a new database and user by running the following SQL commands:
$ createdb gogs $ createuser --encrypted --pwprompt gogsWhen 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
gogsdatabase:$ psql # GRANT ALL PRIVILEGES ON DATABASE gogs TO gogs; # \qThis will grant full privileges to the user
gogson thegogsdatabase.Exit from the
postgresqluser account:# exit
Step 3: Download and Configure Gogs
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.gzExtract the downloaded file:
$ tar -xzf gogs_v0.12.3_openbsd_amd64.tar.gzMove 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
gogsfolder:$ cd /home/gogs/gogs/Create a new
app.inifile to configure the Gogs settings:$ cp conf/app.ini.sample conf/app.iniOpen the
app.inifile using your favorite text editor. For example, we'll usevi:$ vi conf/app.iniEdit 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_KEYvalue to a secure and random string. For example:[security] INSTALL_LOCK = true SECRET_KEY = 53ubx0rk7g8no37ptys2wv61m5649ijhefdchlazqm INTERNAL_TOKEN = X578GBpxiiojsaM0MJBjShcIFZonOPaA
Save and close the
app.inifile.
Step 4: Start Gogs
Change the owner of the
gogsdirectory to thewwwuser:$ 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 webIf 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:3000andssh://localhost:2222.Open your web browser and visit
http://localhost:3000to access the Gogs installation wizard.Follow the wizard to complete the installation process.
Congratulations! You have successfully installed Gogs on OpenBSD.