官方网站:https://gogs.io
官方仓库:https://github.com/gogs
安装方式
- 二进制安装:https://gogs.io/docs/installation/install_from_binary
- 源码安装:https://gogs.io/docs/installation/install_from_source
二进制安装详细步骤
1.创建git用户
$ useradd git
$ passwd git //设置密码(xxxxx)
2.下载解压gogs
默认工作目录在:/home/git/
$ su git
$ cd ~
$ wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.zip
$ unzip gogs_0.11.91_linux_amd64.zip # unzip 命令不可用的话需先安装
3.配置gogs守护进程模式
切回root用户拷贝文件
su root
cd /home/git/gogs
#拷贝服务
sudo cp ./scripts/systemd/gogs.service /usr/lib/systemd/system/
#拷贝到init.d
sudo cp ./scripts/init/centos/gogs /etc/init.d/
#给予可执行权限
chmod +x /etc/init.d/gogs
#设置开机启动服务
systemctl enable gogs.service
#运行服务
systemctl start gogs.service
如果运行失败,请给于目录权限:chmod -R 777 gogs
,然后注意运行的用户。
4.其他命令:
#停止
systemctl stop
#状态
systemctl status
#重启
systemctl restart
#禁用服务
systemctl disable
#重载系统所有服务
systemctl daemon-reload
5.反向代理
#PROXY-START/
location ^~ /
{
try_files $uri @gogs;
}
location @gogs{
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
set $static_fileOuNiwYZ0 0;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_fileOuNiwYZ0 1;
expires 1m;
}
if ( $static_fileOuNiwYZ0 = 0 )
{
add_header Cache-Control no-cache;
}
}
#PROXY-END/
相关文档:https://www.jianshu.com/p/a6be0f87f0c8
版权属于:大卫科技Blog
本文链接:https://www.iyuu.cn/archives/360/
转载时须注明出处