Gitea is a lightweight and easy-to-use self-hosted Git service written in Go. In this tutorial, we will explain how to install Gitea on OpenBSD.
Before we proceed with the installation, you need to ensure that your OpenBSD server meets the following requirements:
We recommend that you update your system before installing any new software. To do this, log in to your OpenBSD server as root or a user with sudo access and run the following command:
$ sudo pkg_add -u
This will update all the packages installed on the OpenBSD system to their latest versions.
Before you can install Gitea, you need to install several dependencies required by Gitea. Run the following command to install them:
$ sudo pkg_add go git postgresql-server
Gitea requires a PostgreSQL database. Create a new PostgreSQL database and user for Gitea by running the following commands:
$ sudo su - _postgresql
$ initdb -D /var/postgresql/data
$ pg_ctl -D /var/postgresql/data start
$ createuser -d -P gitea
Enter password for new role:
Enter it again:
$ createdb -O gitea gitea
$ exit
The above commands will create a new PostgreSQL user called "gitea" with a password, create a new database named "gitea" owned by the "gitea" user. Make sure to remember the password you set for the "gitea" user.
Download the latest version of Gitea from the official website using the following command:
$ sudo su - gitea
$ mkdir gitea
$ cd gitea
$ export VERSION=1.14.3
$ fetch https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-openbsd-amd64
$ chmod +x gitea-${VERSION}-openbsd-amd64
Configure the Gitea server by editing the server configuration file /etc/rc.conf.local
and adding the following lines:
gitea_flags="\
--port 3000 \
--config /home/gitea/gitea/gitea.conf \
--pid /home/gitea/gitea/gitea.pid \
--env HOME=/home/gitea/ \
--webroot /gitea \
--database-url postgres://gitea:<password>@localhost:5432/gitea \
"
Change the <password>
in --database-url
with the password you set for the "gitea" PostgreSQL user.
Create a new configuration file for Gitea by running the following command:
$ cd ~/gitea
$ ./gitea-${VERSION}-openbsd-amd64 admin generate config
This will generate a sample configuration file for Gitea at /home/gitea/gitea/gitea.conf
.
Edit the generated configuration file /home/gitea/gitea/gitea.conf
to match your preferences, but make sure you update the following values:
[server]
DOMAIN = localhost
ROOT_URL = http://localhost:3000/
HTTP_PORT = 3000
PROTOCOL = http
[database]
DB_TYPE = postgresql
HOST = localhost:5432
NAME = gitea
USER = gitea
PASSWD = <password>
Change localhost
in DOMAIN
and ROOT_URL
if the server is hosted at a different domain, but make sure to use http
instead of https
as we are not configuring SSL.
Finally, start the Gitea server by running the following command:
$ doas /usr/sbin/rcctl enable postgresql
$ doas /usr/sbin/rcctl start postgresql
$ doas /usr/sbin/rcctl enable gitea
$ doas /usr/sbin/rcctl start gitea
In this tutorial, we have shown you how to install and configure Gitea on OpenBSD. You should now have Gitea up and running on your server. You can now access the Gitea web interface by going to http://localhost:3000
in your web browser.
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!