GitLab是利用Ruby on Rails一個開源的版本管理系統,實現一個自託管的Git項目倉庫,可通過Web界面進行訪問公開的或者私人項目。與Github類似,GitLab能夠瀏覽源代碼,管理缺陷和註釋。可以管理團隊對倉庫的訪問,它非常易於瀏覽提交過的版本並提供一個文件歷史庫。團隊成員可以利用內置的簡單聊天程序(Wall)進行交流。它還提供一個代碼片段收集功能可以輕鬆實現代碼複用,便於日後有需要的時候進行查找。
Nginx:靜態web服務器。
gitlab-shell:用於處理Git命令和修改authorized keys列表。
gitlab-workhorse: 輕量級的反向代理服務器。
logrotate:日誌文件管理工具。
postgresql:數據庫。
redis:緩存數據庫。
sidekiq:用於在後臺執行隊列任務(異步執行)。
unicorn:An HTTP server for Rack applications,GitLab Rails應用是託管在這個服務器上面的。
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/el6 Repo_gpgcheck=0 Enabled=1 Gpgkey=https://packages.gitlab.com/gpg.key
②更新本地yum緩存
sudo yum makecache
③重置GPG keys
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
④安裝gitlab社區版
sudo yum intall gitlab-ce #自動安裝最新版 或 sudo yum install gitlab-ce-x.x.x #安裝指定版本
sudo gitlab-ctl start # 啓動所有 gitlab 組件; sudo gitlab-ctl stop # 停止所有 gitlab 組件; sudo gitlab-ctl restart # 重啓所有 gitlab 組件; sudo gitlab-ctl status # 查看服務狀態; sudo gitlab-ctl reconfigure # 啓動服務; sudo vim /etc/gitlab/gitlab.rb # 修改默認的配置文件; gitlab-rake gitlab:check SANITIZE=true --trace # 檢查gitlab; sudo gitlab-ctl tail # 查看日誌;
修改gitlab的域名配置
vim /etc/gitlab/gitlab.rb
因爲筆者在本地搭建的,故配置成自己的ip,如果有條件也可配置成自己服務器域名
external_url 'http://11.239.163.102'
執行如下命令,使其生效
sudo gitlab-ctl reconfigure
啓動服務後,直接訪問服務器ip就能訪問gitlab,第一次登錄使用的用戶名和密碼爲 root 和 5iveL!fe,然後設置自己的登錄密碼
sudo apt-get install git cd ~/ && ssh-****** -t rsa -C "your username" cat ~/.ssh/id_rsa.pub 得到**設置在gitlab上 http://${your server ip}/profile/keys 添加
好了,然後就可以用gitlab管理項目了!