1.安装依赖git
在root用户下执行web
$: sudo yum install curl openssh-server openssh-clients postfix cronie -y $: sudo service postfix start $: sudo chkconfig postfix on $: sudo lokkit -s http -s ssh
2.添加Gitlab仓库,并安装在服务器上vim
版本说明: 本文使用的是国内镜像下载安装方式,比国外网站下载速度快;浏览器
CentOS (内核6.x)https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6,选择须要的版本进行安装。服务器
CentOS (内核7.x)https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7,选择须要的版本进行安装。ssh
$: cd /usr/local/src $: wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-8.16.4-ce.0.el6.x86_64.rpm $: rpm -ivh gitlab-ce-8.16.4-ce.0.el6.x86_64.rpm
3.gitlab-ce设置curl
新建/etc/yum.repos.d/gitlab-ce.repogitlab
$: vim /etc/yum.repos.d/gitlab-ce.repo // 添加以下内容 [gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1 $: sudo yum makecache $: sudo yum install gitlab-ce
4.建立gitlab.rb配置文件post
$: sudo mkdir -p /etc/gitlab $: sudo touch /etc/gitlab/gitlab.rb $: sudo chmod 600 /etc/gitlab/gitlab.rb
5.添加web访问的IP地址网站
$: vim /etc/gitlab/gitlab.rb // 添加一下内容 external_url 'http://192.168.1.XXX' # 部署Gitlab的主机IP
6.修改/var/opt/gitlab/gitlab-rails/etc/gitlab.yml文件
$: vi /var/opt/gitlab/gitlab-rails/etc/gitlab.yml // 修改以下蓝色标出的参数为部署的主机IP ## GitLab settings gitlab: ## Web server settings (note: host is the FQDN, do not include http://) host: 192.168.1.XXX port: 80 https: false ## Email settings # Uncomment and set to false if you need to disable email sending from GitLab (default: true) email_enabled: # Email address used in the "From" field in mails sent by GitLab email_from: gitlab@192.168.1.XXX email_display_name: email_reply_to: email_subject_suffix:
7.启动Gitlab
$: sudo gitlab-ctl reconfigure
注意:每次修改完配置文件,都须要从新生效,执行sudo gitlab-ctl reconfigure
相关命令(供安装人员参考使用):
$: sudo gitlab-ctl start # gitlab启动 $: sudo gitlab-ctl restart # gitlab重启 $: sudo gitlab-ctl stop # gitlab中止 $: sudo gitlab-ctl status # gitlab状态
相关报错: $: gitlab-ctl: command not found
解决方案: $: ln -s /opt/gitlab/bin/gitlab-ctl /usr/bin/gitlab-ctl
8.打开浏览器登陆Gitlab
浏览器地址即为Gitlab的主机地址192.168.1.XXX;
第一次打开会重定向让您修改管理员密码,管理员帐号:root,新建的密码不能小于8位;
设置完毕后使用管理员帐号和密码进入便可。