centos7搭建gitlab(一)

官方文檔:

1.安裝和配置依賴:
sudo yum install curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld

2.下載gitlab包:
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo yum install gitlab-ce

或者想要某個確定的版本
sudo yum install gitlab-ce-7.12.0~omnibus-1.x86_64

這裏要求輸入一個git的package的時候,在官網找一個名字就行。

3.修改external_url:
因爲默認的是localhost的80端口,但是很多時候都會被佔用,在瀏覽器中訪問GitLab出現502錯誤時,
所以打開 /etc/gitlab/gitlab.rb ,搜索external_url,修改爲 external_url 'ip地址:端口號'
除了 80 端口外,還有一個unicorn用的端口,默認是8080,如果8080端口被其他程序佔用。那麼unicorn就會無法啓動,顯示爲502錯誤,”GitLab is not responding”。
  解決辦法:修改 /etc/gitlab/gitlab.rb
  unicorn['listen']='127.0.0.1'
  unicorn['port']=8801
修改完配置文件後都要重啓一下gitlab的服務:sudo gitlab-ctl reconfigure

4.編譯運行:
sudo gitlab-ctl reconfigure

如果沒有報錯,最後提示類似下面的,就算是成功了:
Running handlers complete
Chef Client finished


如果報錯了,Gitlab 默認的日誌文件存放在/var/log/gitlab/reconfigure 目錄下,可以看一下具體的錯誤信息。
ERROR: execute[semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp] (gitlab::selinux line 20) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '127'
---- Begin output of semodule -i /opt/gitlab/embedded/selinux/rhel/7/gitlab-7.2.0-ssh-keygen.pp ----
解決方案:sudo yum install libsemanage-static libsemanage-devel
然後重啓:sudo gitlab-ctl reconfigure 

然後就可以輸入之前配置的external_url的ip地址:端口號來登錄了,賬號默認是root,第一次登錄會要求輸入密碼,寫一個自己心儀的密碼就好。

5.gitlab 常用命令
  gitlab-ctl start
  gitlab-ctl stop
  gitlab-ctl status
  gitlab-ctl restart

  gitlab-ctl tail #查看所有日誌
  gitlab-ctl tail nginx/gitlab_access.log #查看nginx訪問日誌


注:調用gitlab-ctl start的時候
錯誤:warning: Insecure world writable dir /usr/local/mysql/bin in PATH, mode 040777。
提示含義:
目錄被賦予777的權限,不安全。
解決方案:將提示權限改爲775。
sudo chmod go-w /usr/local/mysql/bin

sudo chmod 775 /usr/local/mysql


centos7搭建gitlab(二)會介紹如何完成gitlab的倉庫遷移

http://blog.csdn.net/u012887385/article/details/73885214

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章