centos7安裝部署gitlab服務器

我這裏使用的是centos 7 64bit,我試過centos 6也是能夠的!html

1. 安裝依賴軟件nginx

yum -y install policycoreutils openssh-server openssh-clients postfixgit

2.設置postfix開機自啓,並啓動,postfix支持gitlab發信功能redis

systemctl enable postfix && systemctl start postfixsql

3.下載gitlab安裝包,而後安裝vim

centos 6系統的下載地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6centos

centos 7系統的下載地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7服務器

個人是centos7,因此我在https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7中找了個gitlab8.0.0版本,建議下載一個比較新的版本,我這裏選了一個比較舊的版本僅僅是實驗ssh

下載rpm包並安裝:ide

wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

4.修改gitlab配置文件指定服務器ip和自定義端口:

vim  /etc/gitlab/gitlab.rb

退出並保存

ps:注意這裏設置的端口不能被佔用,默認是8080端口,若是8080已經使用,請自定義其它端口,並在防火牆設置開放相對應得端口

5.重置並啓動GitLab

執行:

gitlab-ctl reconfigure

gitlab-ctl restart

ok: run: gitlab-git-http-server: (pid 3922) 1s
ok: run: logrotate: (pid 3929) 0s
ok: run: nginx: (pid 3936) 1s
ok: run: postgresql: (pid 3941) 0s
ok: run: redis: (pid 3950) 0s
ok: run: sidekiq: (pid 3955) 0s
ok: run: unicorn: (pid 3961) 1s

提示「ok: run:」表示啓動成功

6.訪問 GitLab頁面

若是沒有域名,直接輸入服務器ip和指定端口進行訪問

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

第一次登陸修改密碼

6.設置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

測試是否能夠郵件通知:

登陸並添加一個用戶,我這裏使用qq郵箱添加一個用戶

登陸qq郵箱,能夠收到郵件通知(若是收不到,請查看垃圾郵箱或者檢查郵件是否被攔截並刪除,若是有請添加到白名單並刪除用戶再從新添加用戶就能夠收到了,不然請檢查郵件日誌並作好相關設置)

 

報錯處理:

一.登陸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權限後,成功解決報錯問題

 

參考gitlab中文官網 https://www.gitlab.cc/downloads/#centos7

 個人博客即將搬運同步至騰訊雲+社區,邀請你們一同入駐:https://cloud.tencent.com/developer/support-plan

相關文章
相關標籤/搜索