CentOS 安装Gogs

笑着哭i 提交于 2019-12-05 11:24:30

CentOS 安装Gogs

一、 下载安装

1. 创建git用户
useradd git
2 安装git
yum install git
3 下载gogs二进制包

下载地址: https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz

wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz
4 解压
tar -zxvf gogs_0.11.91_linux_amd64.tar.gz
5 修改权限
chwon -R git.git /home/git/

二、运行

进入gogs/目录下

1.直接运行
./gogs web
2 后台运行
nohup ./gogs web &
3 访问
http://39.106.178.64:3000/

三、配置

1 访问进行配置
http://39.106.178.64:3000/
2 开机启动
(1)复制启动脚本
cp /home/git/gogs/scripts/init/centos/gogs /etc/init.d/
(2)修改权限
chmod +x /etc/init.d/gogs

#####(3)添加启动

chkconfig /etc/init.d/gogs on 
(4)启动与停止命令
service gogs start    #启动服务
service gogs stop     #停止服务
service gogs restart  #重启服务
chkconfig --list gogs #查看是否生效
3 配置二级域名

#####(1) 在 /etc/nginx/conf.d 新建 git.conf 文件,内容如下:

upstream git {
 server localhost:3000;
}

server {
    listen       80;
    server_name  git.lwenhao.com;
    client_max_body_size 20M;

    location / {
       proxy_pass http://git;
       proxy_set_header Host $host:$server_port;
       proxy_set_header X-Real_IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Scheme $scheme;
       proxy_connect_timeout 3;
       proxy_read_timeout 3;
       proxy_send_timeout 3;
       access_log off;
       break;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
 }
}
(2) 访问
http://git.lwenhao.com/
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!