Show pageBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Gogs ====== ===== Installation ===== ${shell}:~$ sudo apt-get install postgresql postgresql-contrib ${shell}:~$ sudo apt-get install mercurial git ${shell}:~$ wget https://dl.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.tar.gz ${shell}:~$ tar -zxf gogs_0.11.66_linux_amd64.tar.gz ${shell}:~$ mv gogs* /opt/gogs ${shell}:~$ sudo chown $USER:$USER /opt/gogs -R ## test installation ${shell}:~$ /opt/gogs/gogs web ${shell}:~$ curl localhost:3000 ===== Setup ===== See [[selfhosted:psql|PostgreSQL]] to - install - create user - create databases - grant user privileges to the databases See [[selfhosted:apache|APACHE]] to install, configure, and enable site Configuration file: /etc/apache2/sites-available/gogs.conf http: <VirtualHost *:80> DocumentRoot /var/www/html/gogs/ ServerName localhost <Directory /var/www/html/gogs/> Options +FollowSymLinks AllowOverride All Require all granted <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/gogs SetEnv HTTP_HOME /var/www/html/gogs </Directory> ProxyPreserveHost on ProxyRequests off ProxyPass / http://127.0.0.1:3000 ProxyPassReverse / http://127.0.0.1:3000 ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined </VirtualHost> https: <VirtualHost *:80> DocumentRoot /var/www/html/gogs/ ServerName localhost ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined <Location /> RewriteEngine on RewriteCond %{HTTPS} off RewriteRule (.*) https://${HTTP_HOST}%{REQUEST_URI} [R] </Location> </VirtualHost> <VirtualHost *:443> DocumentRoot /var/www/html/gogs/ ServerName localhost ErrorLog ${APACHE_LOG_DIR}/gogs_error.log CustomLog ${APACHE_LOG_DIR}/gogs_access.log combined SSLEngine On SSLCertificateFile /etc/apache2/ssl/crt/gogs.crt SSLCertificateKeyFile /etc/apache2/ssl/key/gogs.key <Location /> SSLRequireSSL On SSLVerifyClient optional SSLVerifyDepth 1 SSLOptions +StdEnvVars +StrictRequire </Location> <Directory /var/www/html/gogs/> Options +FollowSymLinks AllowOverride All Require all granted <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/gogs SetEnv HTTP_HOME /var/www/html/gogs </Directory> ProxyPreserveHost on ProxyRequests off ProxyPass / http://127.0.0.1:3000 ProxyPassReverse / http://127.0.0.1:3000 </VirtualHost> autostart: ## add init info for LSB tags and overrides $ sudo nano /etc/init.d/gogs < /etc/init.d/gogs > #!/bin/bash ### BEGIN INIT INFO # Provides: gogs # Required-Start: $local_fs $network postgresql # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: gogs # Description: gogs pop & imap daemon ### END INIT INFO PID=`id -u user1` PIDFILE=/var/run/gogs.pid WORKDIR="/opt/gogs" CMD=`su $USERNAME - -c "cd $WORKDIR; PATH=$PATH:$WORKDIR gogs web"` case "$1" in start) start-stop-daemon --start --user $PID --pidfile $PIDFILE --chuid $PID --exec $CMD ;; stop) start-stop-daemon --stop --user $PID --pidfile $PIDFILE --chuid $PID ;; esac exit 0 $ sudo chmod +x /etc/init.d/gogs $ sudo nano /lib/systemd/system/gogs.service < /lib/systemd/system/gogs.service > [Unit] Description=Gogs After=postgresql.service [Service] Type=oneshot ExecStart=/etc/init.d/gogs start RemainAfterExit=no User=user1 Group=user1 [Install] WantedBy=multi-user.target $ sudo update-rc.d gogs defaults $ sudo systemctl enable gogs ===== Misc ===== ## backup $ /opt/gogs/gogs backup $ PGPASSWORD="62oCDajIgcjSXgCumh2A" pg_dump -c -d gogs -U gogsuser -h localhost > /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ## restore $ /opt/gogs/gogs restore $ psql -d gogs -f /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ## $psql gogs < /home/user1/Documents/Backups/databases/dump_gogs_`date +%Y-%m-%d`.sql ===== Errors ===== ## empty repository showing in gogs ## fix: change IS_BARE field of the REPOSITORY table to f $ psql --host=localhost --dbname=gogs --username=gogsuser --password psql~$ \d+ repository psql~$ UPDATE repository SET is_bare = 'f' WHERE is_bare = 't'; selfhosted/gogs.txt Last modified: 2023/07/03 01:43by hli