部署本地gitlab

1、gitlab簡介nginx

      GitLab是利用 Ruby on Rails 一個開源的版本管理系統,實現一個自託管的Git項目倉庫,可經過Web界面進行訪問公開的或者私人項目。它擁有與Github相似的功能,可以瀏覽源代碼,管理缺陷和註釋。能夠管理團隊對倉庫的訪問,它很是易於瀏覽提交過的版本並提供一個文件歷史庫。團隊成員能夠利用內置的簡單聊天程序(Wall)進行交流。它還提供一個代碼片斷收集功能能夠輕鬆實現代碼複用,便於往後有須要的時候進行查找。git

依賴組件:ruby 1.9.3+,nginx、MySQL,git,redis, Sidekiq。 web

gitlab組件詳解:redis

        nginx:靜態web服務器sql

        gitlab-shell:用於處理git命令和修改authorized keys列表shell

        git-workhorse:輕量級反向代理服務器數據庫

        logrotate:日誌文件管理工具vim

        postgresql:數據庫緩存

        redis:緩存數據庫ruby

        sidekiq:用於在後臺執行隊列任務(異步執行)

        unicorn:gitlab rails應用是託管在這個服務器上面的

最低配置內存2G

相關目錄:

/var/opt/gitlab/git-data/repositories/rot:庫默認存儲目錄

/opt/gitlab:應用代碼和相應的依賴程序

/var/opt/gitlab:gitlab-ctl reconfigure命令編譯後的應用數據和配置文件,不須要人爲修改

/etc/gitlab:配置文件目錄

/var/log/gitlab:此目錄存放gitlab各個組件產生的日誌

/var/opt/gitlab/backups:備份文件生成目錄

特色:

1. Web框架使用Ruby on Rails。

2. 基於MIT代碼發佈協議。

3. 須要gitolite協同工做。

2、安裝gitlab

官網:https://about.gitlab.com/downloads/

清華鏡像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/

安裝依賴:

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

RPM安裝

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

注意:若是安裝不了,請修改yum源

#vim /etc/yum.repos.d/gitlab-ce.repo[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=

# 再執行
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.9.5-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-7.10.0~omnibus.2-1.x86_64.rpm

修改配置文件:

#vim /etc/gitlab/gitlab.rb
external_url 'http://your_ip_address'

配置:

gitlab-ctl reconfigure

相關命令:

gitlab-ctl status       查看狀態

gitlab-ctl start          啓動

gitlab-ctl stop          關閉

gitlab-ctl restart       重啓

gitlab-ctl tail nginx   查看nginx日誌

gitlab-ctl show-config   驗證配置

訪問:

http://your_ip_address

blob.png

默認用戶:root

默認密碼:5iveL!fe

登陸後修改密碼!!!!

blob.png

新密碼登陸:

blob.png

項目管理案例:

加入大家公司有一個項目組,包含pm dev1 dev2,一天pm有一個需求須要dev1 dev2完成,那麼咱們應該怎麼去建立組和用戶呢?

建立項目:

blob.pngCreate a new repository and  ssh-key

blob.png

blob.png

git clone git@192.168.56.11:root/car2share.git
cd car2share
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

blob.png