💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# gitlab-ce安装 GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。GitLab拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。 1)基础环境准备 yum install curl policycoreutils openssh-server openssh-clients postfix systemctl start postfix systemctl enable postfix systemctl enable sshd systemctl start sshd 2)安装gitlab-ce curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash yum install -y gitlab-ce 注:由于网络问题,国内用户,建议使用清华大学的镜像源进行安装: [root@git ~]# vim /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=gitlab-ce baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ repo_gpgcheck=0 gpgcheck=0 enabled=1 gpgkey=https://packages.gitlab.com/gpg.key [root@git ~]# yum makecache [root@git ~]# yum install gitlab-ce 3)配置并启动gitlab-ce gitlab-ctl reconfigure 可以使用gitlab-ctl管理gitlab,例如查看gitlab状态: [root@git ~]# gitlab-ctl status run: gitlab-workhorse: (pid 12171) 231s; run: log: (pid 7817) 555s run: logrotate: (pid 12175) 230s; run: log: (pid 7832) 548s run: nginx: (pid 12181) 230s; run: log: (pid 7823) 549s run: postgresql: (pid 12186) 229s; run: log: (pid 7683) 587s run: redis: (pid 12194) 229s; run: log: (pid 7600) 592s run: sidekiq: (pid 12198) 229s; run: log: (pid 7806) 558s run: unicorn: (pid 14967) 6s; run: log: (pid 7774) 560s 关闭gitlab:[root@git ~]# gitlab-ctl stop 启动gitlab:[root@git ~]# gitlab-ctl start 重启gitlab:[root@git ~]# gitlab-ctl restart 登录gitlab 第一次登录gitlab,需要为root用户修改密码,root用户也是gitlab的超级管理员。 ![4-1](http://opnq5yeqm.bkt.clouddn.com/4-1.png) # 配置GitLab主机名 1)修改/etc/gitlab/gitlab.rb文件 mkdir -p /etc/gitlab touch /etc/gitlab/gitlab.rb chmod 600 /etc/gitlab/gitlab.rb 找到如下这段代码,把external_url改成部署机器的域名或者IP地址,如我的电脑ip地址就是 192.168.0.14 ![4-2](http://opnq5yeqm.bkt.clouddn.com/4-2.png) 2)修改/var/opt/gitlab/gitlab-rails/etc/gitlab.yml文件 vim /var/opt/gitlab/gitlab-rails/etc/gitlab.yml ![4-3](http://opnq5yeqm.bkt.clouddn.com/4-3.png) 执行命令:gitlab-ctl reconfigure 如果还是不能正常访问的话,查看80端口是否被占用? 有时候80端口可能被apache给暂用了,针对此问题,直接停用apache服务,或者修改apache的默认端口。 到此为止,gitlab的web管理页面就可以正常访问,并通过自定义域名访问了。 # 端口被占用 如果出现如下页面可以尝试修改gitlab的端口 ![4-4](http://opnq5yeqm.bkt.clouddn.com/4-4.png) vim /etc/gitlab/gitlab.rb 将external_url 直接输入 ip加上端口号 ,比如因为80端口被占用,我直接输入7777端口 external_url 'http://192.168.0.14:7777 ![4-5](http://opnq5yeqm.bkt.clouddn.com/4-5.png) 修改NGINX监听的端口为7777 ![4-6](http://opnq5yeqm.bkt.clouddn.com/4-6.png) 修改完毕之后执行命令:gitlab-ctl reconfigure # 修改Gitlab数据存储路径 默认的Gitlab数据存储路径,在目录/var/opt/gitlab/git-data下,但是新的CentOS服务器根目录分配的空间比较小,为了防止以后数据过大,所以可以修改路径存储为/data/gitlabData。 ![4-7](http://opnq5yeqm.bkt.clouddn.com/4-7.png) 修改完毕之后执行命令:gitlab-ctl reconfigure 设置完后,过一段使用时间,可以看到该目录下的resposities,如下所示: ![4-8](http://opnq5yeqm.bkt.clouddn.com/4-8.png) # 汉化gitlab 1) 安装git yum -y install git 2)克隆获取汉化版本库 下载最新的汉化包 git clone https://gitlab.com/xhang/gitlab.git 如果是要下载老版本的汉化包,需要加上老版本的分支,比如今天已经是10.5.2,我依旧想下载10.0.2,可以运行下面的语句 git clone https://gitlab.com/xhang/gitlab.git -b v10.0.2-zh 3)查看该汉化补丁及gitlab的版本 cat /opt/gitlab/embedded/service/gitlab-rails/VERSION cat gitlab/VERSION ![4-9](http://opnq5yeqm.bkt.clouddn.com/4-9.png) 4)停止gitlab服务 gitlab-ctl stop 5)切换到gitlab汉化包所在的目录(即步骤二获取的汉化版gitlab) cd /root/gitlab 6)比较汉化标签和原标签,导出 patch 用的 diff 文件到/root下 git diff v10.5.2 v10.5.2-zh > ../10.5.2-zh.diff 7)将10.5.2-zh.diff作为补丁更新到gitlab中 cd ~ yum install patch -y patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.5.2-zh.diff 8)重新配置gitlab gitlab-ctl start gitlab-ctl reconfigure 登录gitlab界面查看 ![4-10](http://opnq5yeqm.bkt.clouddn.com/4-10.png) 汉化完成!