CentOS7下安装gitlab、git

本文介绍了在CentOS7系统中如何安装gitlab和git。首先,下载并安装所需的rpm包,包括openssh-server、gitlab-ce和policycoreutils-python。接着,配置gitlab,修改gitlab.rb文件中的外部URL,然后重启服务。最后,安装git,包括解决依赖、解压安装包、编译和配置环境变量。成功后,通过http://192.168.190.147:11000访问gitlab,并设置root用户的密码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装gitlab

1、需要安装包如下:(版本自行网上下载)

openssh-server-6.6.1p1-11.el7.x86_64.rpm

gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm  

policycoreutils-python-2.2.5-15.el7.x86_64.rpm

将三个安装包放到root根目录下

[root@localhost ~]# ls
anaconda-ks.cfg                       openssh-server-6.6.1p1-11.el7.x86_64.rpm
gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm  policycoreutils-python-2.2.5-15.el7.x86_64.rpm

2、按顺序安装下面的依赖,在安装的过程中,也会自动升级很多其他依赖的,所以是在联网情况下安装的。

[root@localhost ~]# yum install -y curl
[root@localhost ~]# yum install -y policycoreutils-python
[root@localhost ~]# yum install -y openssh-server
[root@localhost ~]# yum install gitlab-ce-10.1.4-ce.0.el7.x86_64.rpm

3、安装成功会出现gitlab图标

  #################上面还有很多安装信息,下面是部分截取,出现图标即为安装成功
  正在安装    : gitlab-ce-10.1.4-ce.0.el7.x86_64                                                                     1/1 
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *.                  *.
      ***                 ***
     *****               *****
    .******             *******
    ********            ********
   ,,,,,,,,,***********,,,,,,,,,
  ,,,,,,,,,,,*********,,,,,,,,,,,
  .,,,,,,,,,,,*******,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.
  


     _______ __  __          __
    / ____(_) /_/ /   ____ _/ /_
   / / __/ / __/ /   / __ \`/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/
  

Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

  验证中      : gitlab-ce-10.1.4-ce.0.el7.x86_64                                                                     1/1 

已安装:
  gitlab-ce.x86_64 0:10.1.4-ce.0.el7                                                                                     

完毕!

4、配置gitlab,编辑 vi /etc/gitlab/gitlab.rb文件,将external_url 'http://gitlab.example.com'改为:external_url 'http://192.168.190.147:11000'ip地址+端口号)保存退出。

5、重新配置并重启gitlab,测试环境下可以将防火墙关闭,或者开放指定端口(开放的端口号和刚刚填写的端口号需要一致)

[root@localhost ~]# gitlab-ctl reconfigure   ##重新配置gitlab

[root@localhost ~]# service firewalld stop  ##关闭防火墙

[root@localhost ~]# gitlab-ctl status  ##查看gitlab的运行状态
run: gitaly: (pid 17094) 173s; run: log: (pid 16446) 258s
run: gitlab-monitor: (pid 17132) 172s; run: log: (pid 16795) 222s
run: gitlab-workhorse: (pid 17109) 173s; run: log: (pid 16550) 252s
run: logrotate: (pid 16672) 240s; run: log: (pid 16671) 240s
run: nginx: (pid 16612) 246s; run: log: (pid 16611) 246s
run: node-exporter: (pid 16745) 229s; run: log: (pid 16744) 229s
run: postgres-exporter: (pid 17187) 170s; run: log: (pid 16969) 204s
run: postgresql: (pid 16111) 311s; run: log: (pid 16110) 311s
run: prometheus: (pid 17141) 171s; run: log: (pid 16896) 210s
run: redis: (pid 15988) 317s; run: log: (pid 15987) 317s
run: redis-exporter: (pid 16837) 216s; run: log: (pid 16836) 216s
run: sidekiq: (pid 16385) 264s; run: log: (pid 16384) 264s
run: unicorn: (pid 16317) 270s; run: log: (pid 16316) 270s

10、打开浏览器,访问刚刚配置的地址http://192.168.190.147:11000登录gitlab,第一次登录会让你设置密码的,密码最少为8为,设置完成后即可登录,用户名为root。

二、安装git

1、首先需要安装git的依赖包,并删除已有git

[root@localhost ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
[root@localhost ~]# yum remove git

2、切换到git的包文件存放目录下,这里我是放在了root目录下,进入目录:然后解压安装包

[root@localhost ~]# tar -zxvf git-2.8.3.tar.gz

3、安装包解压完成后,进入解压后的Git文件下,配置安装路径,然后编译并且安装

[root@localhost ~]# cd git-2.8.3
[root@localhost ~]# ./configure prefix=/usr/local/git/   ##配置安装路径
[root@localhost ~]# make && make install   ##编译并且安装


4、将git的指令添加到bash中,运行vi /etc/profile进入编辑,在最后一行添加:

export PATH=$PATH:/usr/local/git/bin

最后运行source /etc/profile命令让上述配置文件立即生效

最后运行git --version命令查看git的版本号

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值