sudo wget https:\/\/github.com\/gogs\/gogs\/releases\/download\/v0.11.86\/linux_amd64.tar.gz<\/pre>\nExtract the archive to the \/opt\/gogs directory:<\/p>\n
tar xvf linux_amd64.tar.gz --strip-components=1 -C \/opt\/gogs<\/pre>\nChange the ownership of the directory to the Gogs user:<\/p>\n
sudo chown -R gogs:gogs \/opt\/gogs\/<\/pre>\nNext, copy the systemd unit file:<\/p>\n
sudo cp \/opt\/gogs\/scripts\/systemd\/gogs.service \/etc\/systemd\/system\/<\/pre>\nOpen the unit file using your preferred text editor – we use nano.<\/p>\n
sudo nano \/etc\/systemd\/system\/gogs.service<\/pre>\nOnce the file is open, edit it as follows:<\/p>\n
[Unit]\r\n[Unit]\r\nDescription=Gogs\r\nAfter=syslog.target\r\nAfter=network.target\r\nAfter=mariadb.service mysqld.service postgresql.service memcached.service redis.service\r\n\r\n[Service]\r\n# Modify these two values and uncomment them if you have\r\n# repos with lots of files and get an HTTP error 500 because\r\n# of that\r\n###\r\n#LimitMEMLOCK=infinity\r\n#LimitNOFILE=65535\r\nType=simple\r\nUser=gogs\r\nGroup=gogs\r\nWorkingDirectory=\/opt\/gogs\r\nExecStart=\/opt\/gogs web\r\nRestart=always\r\nEnvironment=USER=gogs HOME=\/opt\/gogs\r\n\r\n# Some distributions may not support these hardening directives. If you cannot start the service due\r\n# to an unknown option, comment out the ones not supported by your version of systemd.\r\nProtectSystem=full\r\nPrivateDevices=yes\r\nPrivateTmp=yes\r\nNoNewPrivileges=true\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\nSave and close the file, then start and enable the Gogs service:<\/p>\n
sudo systemctl daemon-reload\r\nsudo systemctl start gogs\r\nsudo systemctl enable gogs\r\n<\/pre>\nVerify that the Gogs service is started successfully:<\/p>\n
\u25cf gogs.service - Gogs\r\n Loaded: loaded (\/etc\/systemd\/system\/gogs.service; enabled; vendor preset: enabled)\r\n Active: active (running) since Sun 2019-04-07 12:25:32 CDT; 6min ago\r\n Main PID: 19220 (gogs)\r\n Tasks: 8 (limit: 2320)\r\n CGroup: \/system.slice\/gogs.service\r\n \u2514\u250019220 \/opt\/gogs\/gogs web\r\n\r\nApr 07 12:25:32 localhost systemd[1]: Started Gogs.\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ WARN] Custom config '\/opt\/gogs\/custom\/conf\/app.ini' not found, ignore this if you're running first time\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [TRACE] Custom path: \/opt\/gogs\/custom\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [TRACE] Log path: \/opt\/gogs\/log\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [TRACE] Log Mode: Console (Trace)\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ INFO] Gogs 0.11.86.0130\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ INFO] Cache Service Enabled\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ INFO] Session Service Enabled\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ INFO] SQLite3 Supported\r\nApr 07 12:25:32 localhost gogs[19220]: 2019\/04\/07 12:25:32 [ INFO] Run Mode: Development\r\nApr 07 12:25:33 localhost gogs[19220]: 2019\/04\/07 12:25:33 [ INFO] Listen: http:\/\/0.0.0.0:3000\r\n<\/pre>\n