tar xvf linux_amd64.tar.gz --strip-components=1 -C \/opt\/gogs<\/pre>\nChange the ownership of the extracted 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\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 reload the systemd units:<\/p>\n
sudo systemctl daemon-reload<\/pre>\nFinally, start and enable the Gogs service:<\/p>\n
sudo systemctl start gogs\r\nsudo systemctl enable gogs\r\n<\/pre>\nVerify that the Gogs service is started successfully:<\/p>\n
sudo systemctl status gogs\r\n<\/pre>\n\u25cf gogs.service - Gogs\r\n Loaded: loaded (\/etc\/systemd\/system\/gogs.service; enabled; vendor preset: disabled)\r\n Active: active (running) since Wed 2019-05-01 10:33:40 CDT; 3s ago\r\n Main PID: 1111 (gogs)\r\n CGroup: \/system.slice\/gogs.service\r\n \u2514\u25001111 \/opt\/gogs\/gogs web\r\n\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ WARN] Custom config '\/opt\/gogs\/custom\/conf\/app.ini' not found, ignore this if you're running first time\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [TRACE] Custom path: \/opt\/gogs\/custom\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [TRACE] Log path: \/opt\/gogs\/log\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [TRACE] Log Mode: Console (Trace)\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ INFO] Gogs 0.11.86.0130\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ INFO] Cache Service Enabled\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ INFO] Session Service Enabled\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ INFO] SQLite3 Supported\r\nMay 01 10:33:40 vps gogs[1111]: 2019\/05\/01 10:33:40 [ INFO] Run Mode: Development\r\nMay 01 10:33:41 vps gogs[1111]: 2019\/05\/01 10:33:41 [ INFO] Listen: http:\/\/0.0.0.0:3000\r\n<\/pre>\n