gitlab安裝

建yum源
vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
安裝
yum -y install gitlab-ce
編輯配置文件:vim /etc/gitlab/gitlab.rb
external_url 'https://10.10.144.175' #修改爲你的域名或者ip地址

gitlab-ctl reconfigure  #配置並啓動英文版
gitlab-ctl start  #啓動後如果不能訪問,沒有監聽80端口,則手動啓動

初始賬戶: root 密碼: 5iveL!fe

重建配置
gitlab-ctl reconfigure

#啓停
gitlab-ctl start
gitlab-ctl stop

安裝中文補丁
gitlab-ctl stop
yum install git
git clone https://gitlab.com/xhang/gitlab.git -b v11.0.1-zh #這裏需要與實際版本號對應
cd gitlab/
git diff v11.0.1 v11.0.1-zh > ../v11.0.1-zh.diff   #這裏需要與實際版本號對應。(cat gitlab/VERSION)
yum install patch -y
cd ../
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < v11.0.1-zh.diff
在打補丁時可能會提示找不到文件,這種情況可能時因爲安裝的gitlab目錄下沒有對應的文件,如:/opt/gitlab/embedded/service/gitlab-rails/app目錄下沒有assets目錄。這時可以從git clone下來的源碼目錄找到app/assets目錄,將整個assets目錄複製到/opt/gitlab/embedded/service/gitlab-rails/app目錄下,然後再執行上邊的patch命令。

gitlab-ctl start
gitlab-ctl reconfigure

啓用https:
生成證書:
openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout /etc/gitlab/ssl/server.key -out /etc/gitlab/ssl/server.crt

編輯配置文件:vim /etc/gitlab/gitlab.rb
nginx['enable'] = true
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"

設置gitlab發信功能
需要注意一點:發信系統用的默認的postfix,smtp是默認開啓的,兩個都啓用了,兩個都不會工作。
我這裏設置關閉smtp,開啓postfix
關閉smtp方法:vim /etc/gitlab/gitlab.rb
找到#gitlab_rails['smtp_enable'] = true 改爲 gitlab_rails['smtp_enable'] = false
修改後執行gitlab-ctl reconfigure
另一種是關閉postfix,設置開啓smtp,相關教程請參考官網https://doc.gitlab.cc/omnibus/settings/smtp.html
測試是否可以郵件通知:9
登錄並添加一個用戶,我這裏使用qq郵箱添加一個用戶

常見錯誤
安裝Gitlab後出現“Whoops, GitLab is taking too much time to respond.”兩種原因:
第一種:端口8080被佔用
第二種:內存小於2G

一.登錄502報錯

一般是權限問題,解決方法:chmod -R 755 /var/log/gitlab
如果還不行,請檢查你的內存,安裝使用GitLab需要至少4GB可用內存(RAM + Swap)! 由於操作系統和其他正在運行的應用也會使用內存, 所以安裝GitLab前一定要注意當前服務器至少有4GB的可用內存. 少於4GB內存會出現各種詭異的問題, 而且在使用過程中也經常會出現500錯誤.

二.gitlab-ctl reconfigure

報錯n itdb: could not obtain information about current user: Permission denied

Error executing action run on resource 'execute[/opt/gitlab/embedded/bin/initdb -D /var/opt/gitlab/postgresql/data -E UTF8]'

根據報錯信息大概鎖定用戶的權限問題,安裝gitlab-ce會自動添加用戶四個用戶:

gitlab-www:x:497:498::/var/opt/gitlab/nginx:/bin/false

git:x:496:497::/var/opt/gitlab:/bin/sh

gitlab-redis:x:495:496::/var/opt/gitlab/redis:/bin/nologin

gitlab-psql:x:494:495::/var/opt/gitlab/postgresql:/bin/sh

google和百度都搜索不到解決方法,既然出錯提示到權限問題,那麼按照這個方向去查就不會有問題,後來查了文件/etc/passwd的權限是600,給予644權限後,成功解決報錯問題

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