{{tag>git}} ====== Install gogs on Debian 8 Jessie with nginx as reverse proxy ====== Install mysql 5.7 version, git and sudo (for earler mysql version see gogs script below): wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb dpkg -i mysql-apt-config_0.8.9-1_all.deb apt update apt install mysql-server git sudo nginx Add user gogs, and add her to sudo group: useradd -m -s /bin/bash gogs -G sudo passwd gogs Download package: su - gogs wget https://dl.gogs.io/0.11.34/linux_amd64.tar.gz tar xzvf linux_amd64.tar.gz Run script to create gogs database: sudo mysql -p < gogs/scripts/mysql.sql If using mysql version before 5.7 export the created database and append ROW_FORMAT=DYNAMIC to every CREATE TABLE statement. Then: DROP DATABASE IF EXISTS gogs; CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'gogsuser'@'localhost' IDENTIFIED BY 'sql'; GRANT ALL PRIVILEGES ON `gogs`.* TO 'gogsuser'@'localhost'; SHOW GRANTS FOR gogsuser@localhost; Add this to /etc/mysql/mariadb.conf.d/50-server.cnf innodb_file_format = Barracuda innodb_file_format_max = Barracuda innodb_large_prefix = 1 Import sql script with appended ROW_FORMAT=DYNAMIC: mysql -p gogs < fulldump_gogs_dynamic.sql And restart mysql. Setup gogs as system service: sudo cp gogs/scripts/systemd/gogs.service /etc/systemd/system/ Change entries in service file according to the user you created in previous steps (i.e. deafult 'git' user to 'gogs' in this case) Configure nginx: vi /etc/nginx/sites-available/gogs server { listen 80 default_server; listen [::]:80 default_server; server_name git.example.com; return 301 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name git.example.com; ssl on; ssl_protocols TLSv1.2; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256; ssl_certificate /etc/nginx/ssl/example.com.crt; ssl_certificate_key /etc/nginx/ssl/example.com.key; proxy_set_header X-Real-IP $remote_addr; # pass on real client IP location / { proxy_pass http://localhost:3000; } } ln -s /etc/nginx/sites-available/gogs /etc/nginx/sites-enabled/gogs Reload nginx service and enable and start gogs service: systemctl restart nginx.service systemctl enable gogs.service systemctl start gogs.service Navigate to git.example.com/install and enter sql password and user to run as (in this example 'gogs') in appropriate fields. For security, to only enable logged in users to explore repos, in /home/gogs/gogs/custom/conf/app.ini change edit this line to look like: [service] REQUIRE_SIGNIN_VIEW = true ====== Tested on ====== * Debian 8 ====== See also ====== ====== References ======