Gitlab安装
Gitlab 安装1.环境
软件
版本
操作系统
Debian
10
极狐Gitlab
极狐Gitlab
14.10 2.下载极狐Gitlab14.10
操作系统
下载地址
Debian 9
https://omnibus.gitlab.cn/debian/stretch/gitlab-jh_14.10.0-jh.0_amd64.deb
Debian10
https://omnibus.gitlab.cn/debian/buster/gitlab-jh_14.10.0-jh.0_amd64.deb 3.准备安装
执行如下命令: apt-get update apt-get install -y curl openssh-server ca-certificates perl4.安装
安装并设置访问极狐GitLab 实例的 URL ,执行如下命令: sudo EXTERNAL_URL="http://xxx.xxx.xxx.xxx" dpkg -i gitlab-jh_14.10.0-jh.0_amd64.deb
安装完成后,显示如下: *. *. *** *** ***** ***** .****** ******* ******** ******** ,,,,,,,,,***********,,,,,,,,, ,,,,,,,,,,,*********,,,,,,,,,,, .,,,,,,,,,,,*******,,,,,,,,,,,, ,,,,,,,,,*****,,,,,,,,,. ,,,,,,,****,,,,,, .,,,***,,,, ,*,. ___ __ __ _______ __ __ __ / (_) / / /_ __ / ____(_) /_/ / ____ _/ /_ __ / / / /_/ / / / / / / __/ / __/ / / __ `/ __ / /_/ / / __ / /_/ / / /_/ / / /_/ /___/ /_/ / /_/ / ____/_/_/ /_/__,_/ ____/_/__/_____/__,_/_.___/ Thank you for installing JiHu GitLab! GitLab should be available at http://xxx.xxx.xxx.xxx For a comprehensive list of configuration options please see the Omnibus GitLab readme https://jihulab.com/gitlab-cn/omnibus-gitlab/-/blob/main-jh/README.md Help us improve the installation experience, let us know how we did with a 1 minute survey: https://wj.qq.com/s2/10068464/dc665.验证检查
执行如下命令进行验证检查: # 验证配置文件 gitlab-ctl show-config # 检查 gitlab gitlab-rake gitlab:check SANITIZE=true --trace # 查看服务状态 gitlab-ctl status
如果状态正常的情况下,此时可以从浏览器访问: http://xxx.xxx.xxx.xxx ,显示如下:
6.显示502
当访问对应的地址时,如果显示下图所示:
则可能原因为:内存较小或者端口冲突。
1.检查内存 free -m total used free shared buff/cache available Mem: 7596 5223 410 139 1962 1935
如果内存空间足够,说明不是内存的问题。因为 Gitlab 比较耗内存。
2.端口冲突
Gitlab的webcache系统默认使用8080端口。所以需要检查 8080 端口是否被别的应用程序占用。
检查方法: # netstat -tunlp | grep 8080 tcp6 0 0 :::8080 :::* LISTEN 883/java # ps -ef | grep 883 root 883 1 0 Apr20 ? 00:08:19 /usr/local/jdk1.8.0_211/bin/java -Dzookeeper.log.dir=/usr/local/apache-zookeeper-3.7.0-bin/bin/../logs
上面是我在实际安装过程中的情况,端口 8080 已经被 zookeeper 占用。
3.解决端口冲突
修改配置文件gitlab.rb,该文件一般在/etc/gitlab/gitlab.rb,或者可以使用 find 命令查找: find / -name gitlab.rb
修改文件中的如下内容: # gitlab_workhorse["auth_backend"] = "http://localhost:8080" # puma["port"] = 8080
把前面的注释打开,然后修改成其他未占用的端口, 执行如下命令使其生效: gitlab-ctl reconfigure gitlab-ctl restart
由于 Gitlab 启动较慢,所以隔一会儿再用浏览器请求,来检查是否能正常访问。 7.配置 Gitlab 密码
默认情况下 GitLab 会自动为初始管理员用户账号 (root) 生成密码,并将其存储到 /etc/gitlab/initial_root_password文件中。出于安全原因,在安装 24 小时后,此文件会被第一次 gitlab-ctl reconfigure 自动删除。所以我们需要配置 root 密码。
执行如下命令进入 gitlab-rails 控制台: gitlab-rails console
进行如下操作: user = User.find(1) user.password = "密码" user.password_confirmation = "重复密码" user.save quit
重新配置并启动: gitlab-ctl reconfigure gitlab-ctl restart8.登录与配置
通过浏览器登录,登录后如下图:
8.1配置中文界面
登录后选择右上角的用户头像 > Preferences,如下图:
在页面中的 Localization 中设置 Language ,如下图:
选择简体中文,单击 Save changes 按钮。然后刷新页面即可看到页面全部中文显示。 8.2设置用户资料
选择 用户资料,如下图:
可以根据需要设置头像,时区,邮箱等。时区统一设置为 UTC + 8 8.3注册限制
选择 菜单 > 管理员,如下图:
切换到 管理中心,点击 设置 > 通用 > 注册限制,如下图:
将 已启用注册功能 的对勾去掉然后保存即可。 8.4仓库设置
选择 管理中心 中 设置 > 仓库,如下图:
将默认分支设置为 master,并选择完全保护。