Gogs is a github-like open source file/code management system (based on Git), it's very simple to build, and can be used to build a personal private warehouse
Install Mysql,nginx (nginx as reverse proxy) before installing Gogs.
Create a git user
Gogs Run as a git user by default
adduser git
su git
CD to git user home directory/home/git new. SSH folder permissions set to 0755
Install Go
- The latest binary installation package is available on the Go Language website
wget https://storage.googleapis.com/golang/go1.5.2.linux-386.tar.gztar xzvf go1.5.2.linux-386.tar.gzmv go /usr/local/lib/go
Install the Go Language runtime environment
Gogs is written by the go language and needs to be installed Golang running environment
If other programs in the system do not need to run the Go Language program, you can configure the runtime environment only for the GIT user created above, or choose to configure the Go language runtime for all users of the system
- Configure environment variables, switch to user git, and configure the go run environment for that user only
su gitcd ~
- Write Environment variables
vim /etc/profile
Last line Join
export PATH=$PATH:/usr/local/lib/go/bin
- Make environment variables effective
source /etc/profile
The Go language runtime installation is complete
- Test if the Golang is installed successfully
go env
Installing Gogs
- Download the precompiled Binary installation package
Install package versions Address: Https://gogs.io/docs/installation/install_from_binary
su gitcd ~wget -c http://7d9nal.com2.z0.glb.qiniucdn.com/gogs_v0.8.10_linux_386.tar.gztar zxf gogs_v0.8.10_linux_386.tar.gz
- Set up a database
/home/git/gogs/scripts/mysql.sql is a database initialization file
Tip: The database must support the INNODB engine
cd gogsmysql -u root -p < scripts/mysql.sql #(需输入密码)即可初始化好数据库
- Log in to MySQL to create a new user Gogs and assign all permissions for the database gogs to that user
mysql -u root -pgrant all privileges on gogs.* to 'gogs'@'localhost' identified by '密码';flush privileges;exit;
- Edit Gogs/scripts/supervisor/gogs Modify the following
directory=/home/git/gogs/command=/home/git/gogs/gogs web
Everyone changes according to the actual path
Nginx Reverse Proxy
- http
server { server_name 域名或IP; listen 80; location / { # 如果你希望通过子路径访问,此处修改为子路径,注意以 / 开头并以 / 结束 proxy_pass http://127.0.0.1:3000/; }}
- Https
server { listen 443 ssl; server_name 域名或IP; ssl_certificate /path/to/gogs.io.unified.crt; ssl_certificate_key /path/to/gogs.io-decrypted.key; location / { proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:3000 $request_uri; }}
Detailed configuration
The configuration file is in the Gogs directory custom/conf/app.ini
, which is a text file in INI format. For detailed configuration explanations and default values please refer to the official documentation, where the key configuration is probably the following.
RUN_USER
By default git
, specifies which user gogs to run
ROOT
Storage root path for all warehouses
PROTOCOL
If you use the Nginx anti-generation, please use http
, if the direct naked run to the external service, casual
DOMAIN
Domain name. Will affect the SSH clone address
ROOT_URL
The full root path affects the point at which the link on the page is accessed, and the address of the HTTP clone
HTTP_ADDR
Listen to the address, using Nginx suggestions 127.0.0.1
, otherwise 0.0.0.0
you can also
HTTP_PORT
Listening Port, default3000
INSTALL_LOCK
Lock the Installation page
- Mailer related options
Mailer can use Mailgun's free mail delivery service to fill the Mailgun SMTP configuration into the configuration.
Run Gogs
- Manually turn on Gogs
su gitcd ~/gogs./gogs web
- Join Service Run
Copy/home/git/gogs/scripts/init/debian/gogs to/ETC/INIT.D
Root user under Service Gogs stop|start|restart|reload|status
CentOS Installation: https://www.jianshu.com/p/c9ca7c16bd1f