1
Forgejo Install from Binary
T20A02 edited this page 2024-08-22 20:38:10 -04:00
Installation:
- Download Forgejo binary for your CPU architecture and verify the GPG signature.
- Copy the binary to
/usr/local/bin/and make it executable.
# cp forgejo-1.21.5-0-linux-amd64 /usr/local/bin/forgejo
# chmod 755 /usr/local/bin/forgejo
- Ensure
gitandgit-lfsare installed:
# apt install git git-lfs
- Create a user
giton the system:
# adduser --system --shell /bin/bash --gecos 'Git Version Control' \
--group --disabled-password --home /home/git git
- Create necessary directories for Forgejo:
# mkdir /var/lib/forgejo
# chown git:git /var/lib/forgejo && chmod 750 /var/lib/forgejo
# mkdir /etc/forgejo
# chown root:git /etc/forgejo && chmod 770 /etc/forgejo
Optional: Set up database: (If not using SQLite)
- Follow Forgejo's Database Preparation guide for setup.
Install systemd service for Forgejo:
- Download the systemd service script:
# wget -O /etc/systemd/system/forgejo.service https://codeberg.org/forgejo/forgejo/raw/branch/forgejo/contrib/systemd/forgejo.service
- Enable and start the Forgejo service:
# systemctl enable forgejo.service
# systemctl start forgejo.service
Forgejo's web-based configuration:
- Access Forgejo in your browser at
http://git.example.com:3000/. - If encountering issues, check service status and logs:
# systemctl status forgejo.service
# journalctl -n 100 --unit forgejo.service
- Follow on-screen instructions to complete initial configuration.
Further configuration in Forgejo's app.ini:
- Stop Forgejo service:
# systemctl stop forgejo.service
- Make
/etc/forgejo/andapp.iniread-only for the git user:
# chmod 750 /etc/forgejo && chmod 640 /etc/forgejo/app.ini
-
Edit
/etc/forgejo/app.inito adjust configurations. -
Start Forgejo service again:
# systemctl start forgejo.service
General hints for using Forgejo:
- Run Forgejo CLI as the git user.
- Specify Forgejo work path and config path.
- Optionally, create a script for easier CLI usage:
#!/bin/sh
sudo -u git forgejo -w /var/lib/forgejo -c /etc/forgejo/app.ini "$@"
- Make it executable:
# chmod 755 /usr/local/bin/forgejo.sh
Now, Forgejo commands can be executed simply by calling forgejo.sh [command].
To turn the script into a service for systemctl, follow these steps:
- Open the
forgejo.servicefile for editing:
sudo nano /etc/systemd/system/forgejo.service
- Update the file to include the
Userdirective:
[Unit]
Description=Forgejo Command Line Interface
After=network.target
[Service]
Type=simple
User=git
ExecStart=/usr/local/bin/forgejo.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
-
Save and close the file.
-
Reload
systemdto read the new service file:
sudo systemctl daemon-reload
- Enable and start the
forgejoservice:
sudo systemctl enable forgejo.service
sudo systemctl start forgejo.service
Now, the forgejo.sh script will be executed with the git user permissions when managed by systemctl.