sudo 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. This allows us to create a SystemD service for Gogs:<\/p>\n
sudo cp \/opt\/gogs\/scripts\/systemd\/gogs.service \/etc\/systemd\/system\/<\/pre>\nOpen the unit file using your text editor of choice. We’ll 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\/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>\nOnce you’re done editing the file, save it, 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>\nRun the following command to verify 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: enabled)\r\n Active: active (running) since Mon 2019-05-13 02:57:32 CDT; 29s ago\r\n Main PID: 791 (gogs)\r\n CGroup: \/system.slice\/gogs.service\r\n \u2514\u2500791 \/opt\/gogs\/gogs web\r\n\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ WARN] Custom config '\/opt\/gogs\/custom\/conf\/app.ini' not found, ignore this if you're running first time\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [TRACE] Custom path: \/opt\/gogs\/custom\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [TRACE] Log path: \/opt\/gogs\/log\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [TRACE] Log Mode: Console (Trace)\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ INFO] Gogs 0.11.86.0130\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ INFO] Cache Service Enabled\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ INFO] Session Service Enabled\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ INFO] SQLite3 Supported\r\nMay 13 02:57:32 vps gogs[791]: 2019\/05\/13 02:57:32 [ INFO] Run Mode: Development\r\nMay 13 02:57:33 vps gogs[791]: 2019\/05\/13 02:57:33 [ INFO] Listen: http:\/\/0.0.0.0:3000\r\n<\/pre>\n