How to Install Gogs on Arch Linux
Gogs is a self-hosted Git service that provides a lightweight, fast, and easy-to-use platform for managing and collaborating on code. In this tutorial, we will be explaining step-by-step how to install Gogs on Arch Linux.
Prerequisites
- A running Arch Linux system.
- Root or sudo access to your Arch Linux system.
Step 1: Install Dependencies
First, we need to install some dependencies to get started with the Gogs installation.
sudo pacman -S git go
Step 2: Create a Gogs System User
Next, we will create a system user and group for Gogs.
sudo groupadd -r gogs
sudo useradd -r -s /usr/bin/nologin -d /var/opt/gogs -M -g gogs gogs
Step 3: Download and Install Gogs
We will download the latest version of Gogs from its official website.
cd /tmp
wget -O gogs.tar.gz https://dl.gogs.io/gogs_v0.12.3_linux_amd64.tar.gz
tar xf gogs.tar.gz
sudo mv gogs /opt/gogs
sudo chown -R gogs:gogs /opt/gogs
sudo chmod -R 770 /opt/gogs
Step 4: Configure Gogs
Next, we need to configure Gogs by editing the app.ini file.
sudo nano /opt/gogs/custom/conf/app.ini
Under the [server] section, set the http_port value to 3000.
Under the [database] section, set the DB_TYPE to sqlite3 and set the HOST to localhost:3306.
[server]
PROTOCOL = http
DOMAIN =
HTTP_PORT = 3000
ROOT_URL = %(PROTOCOL)s://%(HTTP_HOST)s/
APP_NAME = Gogs
...
[database]
DB_TYPE = sqlite3
HOST = localhost:3306
NAME = gogs
USER = root
PASSWD =
PATH = data/gogs.db
Save and close the file.
Step 5: Create a Systemd Unit File for Gogs
To start Gogs as a service, we need to create a systemd unit file.
sudo nano /etc/systemd/system/gogs.service
Add the following configuration:
[Unit]
Description=Gogs
After=syslog.target
After=network.target
[Service]
User=gogs
Group=gogs
WorkingDirectory=/opt/gogs
ExecStart=/opt/gogs/gogs web
ExecStop=/bin/kill -TERM $MAINPID
Restart=always
Environment=USER=gogs HOME=/var/opt/gogs
[Install]
WantedBy=multi-user.target
Save and close the file.
Step 6: Start and Enable Gogs
Start the Gogs service and enable it to start on boot.
sudo systemctl start gogs
sudo systemctl enable gogs
Step 7: Configure Firewall
If you have enabled firewall on your Arch Linux system, you need to allow access to the Gogs port (default is 3000).
sudo ufw allow 3000/tcp
Step 8: Access Gogs Web Interface
Open a web browser and access Gogs by navigating to http://server_ip:3000.
Conclusion
You have successfully installed and configured Gogs on your Arch Linux system. You can now use it to collaborate on your code projects.