美文网首页
CentOS8安装gitlab

CentOS8安装gitlab

作者: 秋天下雨淋湿冬天 | 来源:发表于2021-12-10 17:12 被阅读0次

    开发环境:

    操作系统 CentOS Linux release 8.2.2004 (Core)
    CPU Intel(R) Xeon(R) Platinum 8269CY CPU @ 2.50GH
    内存 3590MB (安装后内存水位在2800M,2G内存就别玩了)

    1,安装依赖
    yum install -y curl policycoreutils-python openssh-server

    centos8没有policycoreutils-python yum源,不用管

    2,启动ssh并设置为开机自启动
    systemctl enable sshd

    systemctl start sshd

    3,添加http服务到firewalld,pemmanent表示永久生效,若不加--permanent系统下次启动后就会失效
    systemctl start firewalld

    firewall-cmd --permanent --add-service=http

    systemctl reload firewalld

    4,启动postfix

    Failed to start postfix.service: Unit postfix.service not found
    首先看一下服务列表里有没有这个服务:
    systemctl list-unit-files --type=service
    如果有的话:
    systemctl daemon-reload
    没有的话 :
    sudo yum install -y postfix

    systemctl enable postfix

    systemctl start postfix

    5,下载gitlab
    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm

    6,安装
    rpm -i gitlab-ce-12.10.1-ce.0.el8.x86_64.rpm
    成功如图:

    image

    7,编辑ip和端口
    vim /etc/gitlab/gitlab.rb

    这个文件大致都是注释掉的,只有这一句,大概在29行,改成自己的地址
    external_url 'http://localhost:8081'

    这一步会很长
    gitlab-ctl reconfigure

    gitlab-ctl restart

    增加NGINX配置,将你的网址 xxx.xxxxxxxx.xx 绑定到 http://localhost:8081

    server{
        listen 80 ;
        server_name xxx.xxxxxxxx.xx ;
            client_max_body_size 200m;
            location / {
                root  html;
                index index.html index.htm;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header REMOTE-HOST $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://127.0.0.1:8081;
            }
    }
    http{        
        client_max_body_size 200m; // nginx 配置文件 http层级也要加 否则不生效
    }
    

    8,访问
    如果一直无法响应,可以关闭防火墙
    systemctl stop firewalld

    重新配置并启动

    gitlab-ctl reconfigure
    gitlab-ctl restart

    GitLab 常用命令

    gitlab-ctl start 启动所有 gitlab 组件;
    gitlab-ctl stop 停止所有 gitlab 组件;
    gitlab-ctl restart 重启所有 gitlab 组件;
    gitlab-ctl status 查看服务状态;

    9,成功如图:


    image

    10,第一次登录需要修改root密码, 密码8位以上,修改完就可以登录
    使用设置的新密码,登录


    image

    11,修改project的默认域名和端口


    image.png

    注意:gitlab安装时自带了一个NGINX。
    vim /etc/gitlab/gitlab.rb

    external_url 'http://git.xxx.com'    //域名:nginx端口  此处80为独立nginx端口
    nginx['enable'] = false       //禁用自带nginx
    gitlab_workhorse['listen_network'] = "tcp"  //允许gitlab-workhorse监听TCP
    gitlab_workhorse['listen_addr'] = "127.0.0.1:8081" //设置gitlab端口为8091 注意自己的 8091未占用
    gitlab_rails['trusted_proxies'] = ['git.xxx.com']  // 设置gitlab域名
    

    gitlab-ctl reconfigure
    gitlab-ctl restart


    完全卸载删除gitlab

    1、停止gitlab

    gitlab-ctl stop

    2、卸载gitlab(注意这里写的是gitlab-ce)

    rpm -e gitlab-ce

    3、查看gitlab进程

    ps aux | grep gitlab

    image

    4、杀掉第一个进程(就是带有好多.............的进程)

    kill -9 714

    杀掉后,在ps aux | grep gitlab确认一遍,还有没有gitlab的进程

    5、删除所有包含gitlab文件

    find / -name gitlab | xargs rm -rf

    参考链接:
    https://www.cnblogs.com/stronger-xsw/p/12802069.html

    相关文章

      网友评论

          本文标题:CentOS8安装gitlab

          本文链接:https://www.haomeiwen.com/subject/pypcfrtx.html