Gogs is an open-source and lightweight Git service that can be self-hosted. It is cross-platform and designed to be easy to use, making it a good choice for individuals or small teams.
In this tutorial, we will show you how to install Gogs on Clear Linux Latest.
Before installing Gogs on Clear Linux Latest, make sure that you have:
To ensure that your system is up to date, run the following command:
sudo swupd update
If there are any updates available, the command will download and install them.
Git is required to run Gogs. If you have not installed it yet, run the following command:
sudo swupd bundle-add git
Gogs requires a database server to store its data. In this tutorial, we will be using MariaDB. To install MariaDB, run the following command:
sudo swupd bundle-add mariadb
Once installed, start the MariaDB service and enable it to start automatically upon boot:
sudo systemctl enable --now mariadb
Finally, secure your MariaDB installation by running:
sudo mysql_secure_installation
Follow the prompts and set a password for the root user, remove the anonymous user, disallow root login remotely, and remove the test database.
Download and install Gogs using the following command:
sudo mkdir -p /opt/gogs
cd /opt/gogs
sudo wget https://dl.gogs.io/0.12.3/gogs_0.12.3_linux_amd64.tar.gz
sudo tar -zxvf gogs_0.12.3_linux_amd64.tar.gz
Change the ownership of the gogs
directory to the user you plan on running Gogs as. For example, if you plan on running Gogs as user gogs
, run the following command:
sudo chown -R gogs:gogs /opt/gogs
Navigate to the custom/conf
directory and copy the app.ini.sample
file to app.ini
:
cd /opt/gogs/custom/conf
sudo cp app.ini.sample app.ini
Edit the app.ini
file using your preferred text editor. Set the following parameters:
APP_NAME
- Set a name for your Gogs instance.RUN_MODE
- Set the run mode to prod
.UNIX_SOCKET_ENABLED
- Set this to false
if you are not using a UNIX socket for the database connection.DB_TYPE
- Set the database type to mysql
.DB_HOST
- Set the database host to localhost
.DB_NAME
- Set the database name to gogs
.DB_USER
- Set the database username to a non-root user with permission to create databases and users.DB_PASSWD
- Set the password for the database user.Save and close the file.
Log in to your MariaDB server as the root user:
sudo mysql -u root -p
Create a database and a user for Gogs:
CREATE DATABASE gogs;
CREATE USER 'gogs'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost';
FLUSH PRIVILEGES;
Replace 'password' with your desired password for the gogs
user.
Navigate to the Gogs directory and start the Gogs service using the following command:
cd /opt/gogs
sudo -u gogs ./gogs web
Open your web browser and navigate to http://<your_domain_or_IP>:3000
. You will be presented with the Gogs setup page. Follow the prompts to complete the setup process.
Once finished, log in to your Gogs instance and start hosting your repositories!
You have just learned how to install Gogs on Clear Linux Latest. Now you can start self-hosting your own Git service without relying on third-party services. Do remember to update frequently and back up your data regularly, too!
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!