- Project homepage: https://gogs.io
- Download page: https://gogs.io/docs/installation/install_from_binary
- Download address: https://dl.gogs.io/0.11.91/gogs_0.11.91_raspi_armv7.tar.gz
==Note: I log in with the root account to perform all operations. If pi account is used for operation, please add sudo before all instructions==
install
gogs is written in go language. Raspberry official system Raspbian already has a basic running environment. The official website also provides a binary version suitable for Raspberry Pi, so the installation is relatively simple. Upload gogs? 0.11.91? Raspi? Armv7.tar.gz to the raspberry pie directory
1. Decompression
tar -vxf gogs_0.11.91_raspi_armv7.tar.gz
2. Executable found
cd gogs
3. Check whether it can operate
./gogs
Output short help:
root@raspberrypi:/home/pi/soft/gogs # ./gogs NAME: Gogs - A painless self-hosted Git service USAGE: gogs [global options] command [command options] [arguments...] VERSION: 0.11.91.0811 COMMANDS: web Start web server serv This command should only be called by SSH shell hook Delegate commands to corresponding Git hooks cert Generate self-signed certificate admin Perform admin operations on command line import Import portable data as local Gogs data backup Backup files and database restore Restore files and database from backup help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --help, -h show help --version, -v print the version
4. Turn on the server:
./gogs web
root@raspberrypi:/home/pi/soft/gogs # ./gogs web 2020/01/09 15:42:39 [TRACE] Custom path: /home/pi/soft/gogs/custom 2020/01/09 15:42:39 [TRACE] Log path: /home/pi/soft/gogs/log 2020/01/09 15:42:39 [TRACE] Build Time: 2019-09-11 04:31:43 UTC 2020/01/09 15:42:39 [TRACE] Build Git Hash: c154721f4a8f3e24d2f6fb61e74b4b64529255c2 2020/01/09 15:42:39 [TRACE] Log Mode: File (Info) 2020/01/09 15:42:39 [ INFO] Gogs 0.11.91.0811 [Macaron] 2020-01-09 15:42:47: Started GET / for 172.30.34.114 [Macaron] 2020-01-09 15:42:47: Completed GET / 200 OK in 43.815385ms [Macaron] 2020-01-09 15:42:47: Started GET /js/jquery-1.11.3.min.js for 172.3
Sometimes there is a warning that the custom configuration file app.ini is not found.
The next self-service installation process generates a configuration file.
Use a browser to access the IP address of raspberry pie on a PC with the same network segment as raspberry pie, and the port is 3000.
5. Visit site (configure)
http://172.30.34.63:3000
The first run setup page appears with the following configuration:
- Data settings gogs supports MySQL, PostgreSQL, SQLite3 and TiDB. Raspberry sends lightweight services to run. SQLite3 is enough, so this database is a db file on the pi.
- Application basic settingsapplication basic settings are configurations that must be initialized and modified as needed.
- Optional settings if the meaning of optional settings is not clear, you can refer to my settings. Due to small-scale use, the mail service is not configured. The administrator user needs to create one, and the password should be kept in mind.
Finally, click the "install now" button.
Wait a moment, and you 'll jump to the control panel,
This indicates that the installation was successful.
If there is an error, there will also be a prompt. Modify according to the prompt.
Note that this is an administrator user. Generally, it is recommended to only manage ordinary users and not use it to directly manage code.
That is, the administrator user manages the ordinary user, and the ordinary user logs in to the system for code hosting.
6. Add normal user
In the menu in the upper right corner of the web page, select "management panel", which is only available to administrators.
In user management, add a common new user (interface operation, not detailed introduction), create it, then log out and log in with a new account.
==Note that this is an administrator user. Generally, it is recommended to only manage ordinary users and not use it to directly manage code. = =
Keep gogs service started automatically
1. Copy the service script to the system directory
sudo cp /home/pi/soft//gogs/scripts/systemd/gogs.service /etc/systemd/system
2. Modify the configuration of gogs.service
vim /etc/systemd/system
root@raspberrypi:/home/pi/soft/gogs/scripts/systemd # cat gogs.service [Unit] Description=Gogs After=syslog.target After=network.target After=mariadb.service mysqld.service postgresql.service memcached.service redis.service [Service] # Modify these two values and uncomment them if you have # repos with lots of files and get an HTTP error 500 because # of that ### #LimitMEMLOCK=infinity #LimitNOFILE=65535 Type=simple User=git Group=git WorkingDirectory=/home/git/gogs ExecStart=/home/git/gogs/gogs web Restart=always Environment=USER=git HOME=/home/git # Some distributions may not support these hardening directives. If you cannot start the service due # to an unknown option, comment out the ones not supported by your version of systemd. ProtectSystem=full PrivateDevices=yes PrivateTmp=yes NoNewPrivileges=true [Install] WantedBy=multi-user.target
Be careful:
User=git Group=git WorkingDirectory=/home/git/gogs ExecStart=/home/git/gogs/gogs web Restart=always Environment=USER=git HOME=/home/git
Revised to:
User=root Group=root WorkingDirectory=/home/gogs-repositories ExecStart=/home/pi/soft/gogs/gogs web #The start command "ExecStart" is very important. If the configuration is wrong, it will fail to start Restart=always Environment=USER=root HOME=/home/pi/
The default user and path are both git, which is changed to root (or pi).
3. Set power on and self start gogs
systemctl enable gogs
4. Start gogs now:
systemctl start gogs
5. View real time log output
systemctl status gogs
6. Appendix:
For my sample configuration file, please note that some configurations are generated by the system itself. Do not copy them directly. File path:
gogs/custom/conf/app.ini
root@raspberrypi:/home/pi/soft/gogs/custom/conf # cat app.ini APP_NAME = Gogs RUN_USER = root RUN_MODE = prod [database] DB_TYPE = mysql HOST = 172.30.34.63:3306 NAME = gogs USER = root PASSWD = 123456 SSL_MODE = disable PATH = data/gogs.db [repository] ROOT = /home/gogs-repositories # Path to the warehouse root [server] DOMAIN = 172.30.34.63 HTTP_PORT = 8082 ROOT_URL = http://172.30.34.63:8082/ DISABLE_SSH = false SSH_PORT = 22 START_SSH_SERVER = false OFFLINE_MODE = false [mailer] ENABLED = true HOST = smtp.163.com:465 FROM = ***@163.com USER = ****@163.com PASSWD = ***** [service] REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = false DISABLE_REGISTRATION = false ENABLE_CAPTCHA = true REQUIRE_SIGNIN_VIEW = false [picture] DISABLE_GRAVATAR = false ENABLE_FEDERATED_AVATAR = false [session] PROVIDER = file [log] MODE = file LEVEL = Info ROOT_PATH = /home/pi/soft/gogs/log [security] INSTALL_LOCK = true SECRET_KEY = GfUjtoxm6SgpibP