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位;
設置完畢後使用管理員帳號和密碼進入便可。