gitlab安裝指南

GitLab是利用 Ruby on Rails 一個(gè)開源的版本管理系統(tǒng)初肉,實(shí)現(xiàn)一個(gè)自托管的Git項(xiàng)目倉庫,可通過Web界面進(jìn)行訪問公開的或者私人項(xiàng)目轨域。它擁有與Github類似的功能,能夠?yàn)g覽源代碼,管理缺陷和注釋隅茎。可以管理團(tuán)隊(duì)對(duì)倉庫的訪問嫉沽,它非常易于瀏覽提交過的版本并提供一個(gè)文件歷史庫辟犀。團(tuán)隊(duì)成員可以利用內(nèi)置的簡(jiǎn)單聊天程序(Wall)進(jìn)行交流。它還提供一個(gè)代碼片段收集功能可以輕松實(shí)現(xiàn)代碼復(fù)用绸硕,便于日后有需要的時(shí)候進(jìn)行查找堂竟。

官網(wǎng)寫的安裝已經(jīng)很全面,后面基本都是web可視化操作玻佩,考驗(yàn)Git能力出嘹,我這里就照抄下來啦。

Centos 6.7 Install Gitlab

1. Config git info

[root@gitlab-machine ~]# git config --global user.name "whoami"
[root@gitlab-machine ~]# git config --global user.email "whoami@itweet.cn"
[root@gitlab-machine ~]# git config --global color.ui true
[root@gitlab-machine ~]# git config --list
user.name=whoami
user.email=whoami@itweet.cn
color.ui=true

2.Install and configure the necessary dependencies

If you install Postfix to send email please select 'Internet Site' during setup. Instead of using Postfix you can also use Sendmail or configure a custom SMTP server and configure it as an SMTP server.

On Centos 6 and 7, the commands below will also open HTTP and SSH access in the system firewall.

[root@gitlab-machine ~]#  sudo yum install curl openssh-server openssh-clients postfix cronie

[root@gitlab-machine ~]# sudo service postfix start

[root@gitlab-machine ~]# sudo chkconfig postfix on

[root@gitlab-machine ~]# sudo lokkit -s http -s ssh

3. Add the GitLab package server and install the package

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

If you are not comfortable installing the repository through a piped script, you can find the entire script here and select and download the package manually and install using

Download RPM Package:
https://packages.gitlab.com/gitlab/gitlab-ce

curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/6/gitlab-ce-XXX.rpm/download
rpm -i gitlab-ce-XXX.rpm

For example

[root@gitlab-machine ~]# lsof -i :80|wc -l
0

[root@gitlab-machine ~]# netstat -lntp|grep 80|wc -l
0

[root@gitlab-machine ~]# ls -l gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm 
-rwxr-xr-x 1 root root 261779557 May  2 14:06 gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm

[root@gitlab-machine ~]# rpm -ivh gitlab-ce-8.7.0-ce.0.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:gitlab-ce              ########################################### [100%]
hostname: Host name lookup failure
gitlab: Thank you for installing GitLab!
gitlab: To configure and start GitLab, RUN THE FOLLOWING COMMAND:

sudo gitlab-ctl reconfigure

gitlab: GitLab should be reachable at http://gitlab.example.com
gitlab: Otherwise configure GitLab for your system by editing /etc/gitlab/gitlab.rb file
gitlab: And running reconfigure again.
gitlab: 
gitlab: For a comprehensive list of configuration options please see the Omnibus GitLab readme
gitlab: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
gitlab: 
It looks like GitLab has not been configured yet; skipping the upgrade script.

4.Configure and start GitLab

[root@gitlab-machine ~]# sudo gitlab-ctl reconfigure
Starting Chef Client, version 12.6.0
...omit...
Running handlers:
Running handlers complete
Chef Client finished, 221/300 resources updated in 01 minutes 24 seconds
gitlab Reconfigured!

[root@gitlab-machine ~]# lsof -i :80             
COMMAND  PID       USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   2392       root    6u  IPv4  83966      0t0  TCP *:http (LISTEN)
nginx   2394 gitlab-www    6u  IPv4  83966      0t0  TCP *:http (LISTEN)
[root@gitlab-machine ~]# netstat -lnop|grep 80|wc -l
3

修改gitlab倉庫地址

[root@gitlab-server data]# cat /etc/gitlab/gitlab.rb |grep git_data
# git_data_dir "/var/opt/gitlab/git-data"
git_data_dir "/data/gitlab/git-data"

[root@gitlab-server data]# sudo gitlab-ctl reconfigure

[root@gitlab-server data]# sudo gitlab-ctl restart

5咬崔、Browse to the hostname and login

On your first visit, you'll be redirected to a password reset screen to provide the password for the initial administrator account. Enter your desired password and you'll be redirected back to the login screen.

The default account's username is root. Provide the password you created earlier and login. After login you can change the username if you wish.

For configuration and troubleshooting options please see the Omnibus GitLab documentation
If you are located in China, try using https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

訪問地址http://gitlab.itweet.cn:80 (需要提前映射好域名和ip地址到hosts文件),第一次訪問税稼,提示’Change your password‘頁面烦秩,你可以輸入密碼,此密碼即為root密碼郎仆;然后可用此密碼登錄root用戶只祠,比如我這里設(shè)置為root/admin123。
[圖片上傳失敗...(image-f6d7f0-1513993971279)]

6扰肌、入門使用

基本都是web可視化操作抛寝。這里我簡(jiǎn)單減少幾個(gè)概念吧。

6.1 Project 可以發(fā)起一個(gè)項(xiàng)目曙旭,查詢當(dāng)前用戶所擁有或者能管理的項(xiàng)目列表

6.2 Users 用戶管理模塊墩剖,管理員可見。

6.3 Groups 組織機(jī)構(gòu)夷狰,公司管理岭皂;比如一個(gè)公司可以開啟一個(gè)groups下面有很多開發(fā)人員。

6.4 Deploy keys 免密碼ssh驗(yàn)證沼头,git提交或者拉去代碼爷绘,可以免密碼驗(yàn)證。

6.5 SSH keys

當(dāng)我們從GitHub或者GitLab上clone項(xiàng)目或者參與項(xiàng)目時(shí)进倍,我們需要證明我們的身份土至。一種可能的解決方法是我們?cè)诿看卧L問的時(shí)候都帶上賬戶名、密碼猾昆,另外一種辦法是在本地保存一個(gè)唯一key陶因,在你的賬戶中也保存一份該key,在你訪問時(shí)帶上你的key即可垂蜗。GitHub楷扬、GitLab就是采用key來驗(yàn)證你的身份的,并且利用RSA算法來生成這個(gè)密鑰贴见。

[root@gitlab-machine ~]# git config --list
user.name=whoami
user.email=whoami@itweet.cn
color.ui=true

[root@gitlab-machine ~]# ssh-keygen -t rsa -C "whoami@itweet.cn"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
05:07:1c:92:ec:ec:79:cd:09:96:a3:8e:a3:13:bf:e2 xujiang@itweet.cn
The key's randomart image is:
+--[ RSA 2048]----+
|     ..o+o.      |
|      o..o       |
|     o   ..      |
|      o =.       |
|     . +S= .     |
|  .   + . +      |
|   o o .         |
|  o + .          |
| .E+.o           |
+-----------------+

[root@gitlab-machine ~]# cat .ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtWly2W39tM88fNrPHDoutQUe/iZZonOs/Qf8ZVxF+Kyivj8PrvlR83MmPoBbGwF/YOn5EHROEBy2EAFCHk+zQZ9uHJlsRF4EU6Aq5yZBfOTA8erdllDIy25BLITAhNe4AXmcGKJMl/TmNBWmN5+GjmTyL5l85+hMTUM3cUT8WVhPDFGlm+3UPh1AwptlDOe+t0XX6dl39BZ3i1CTmh+X38Q1K7RHkIjSSeUZQANGzJlfENQqse/zhENvUftk4EwRXL6+RIPwdk+ijAvnKGIwIfSx75u51E29jvvnP8FidU0HnBsbbedFg6cWlnMj/6AgXxnP22skmEBRAlRb7qO/zQ== xujiang@itweet.cn

添加烘苹,id_rsa.pub到ssh keys 頁面,即可完成認(rèn)證片部。如下驗(yàn)證:

[root@gitlab-machine data]# git clone git@gitlab.itweet.cn:xujiang/test.git
Initialized empty Git repository in /data/test/.git/
The authenticity of host 'gitlab.itweet.cn (192.168.1.125)' can't be established.
RSA key fingerprint is d4:2d:bb:87:cf:41:ff:fd:64:b7:66:56:45:f2:d1:64.
Are you sure you want to continue connecting (yes/no)? yes 
Warning: Permanently added 'gitlab.itweet.cn,192.168.1.125' (RSA) to the list of known hosts.
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (6/6), 4.30 KiB, done.
remote: Total 6 (delta 0), reused 0 (delta 0)

[root@gitlab-machine data]# pwd
/data

[root@gitlab-machine data]# tree
.
└── test
    ├── LICENSE
    └── README.md

2 directories, 2 files

For Examples

[root@gitlab-machine data]# cd test/

[root@gitlab-machine test]# cat hello.py 
#!/usr/bin/python
print("hello itweet.cn!")

[root@gitlab-machine test]# git add hello.py 

[root@gitlab-machine test]# git commit -m 'first python script...'
[master 25bddfa] first python script...
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 hello.py

[root@gitlab-machine test]# git push origin master
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 351 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitlab.itweet.cn:whoami/test.git
   f0eb0f6..25bddfa  master -> master

6.6 導(dǎo)入項(xiàng)目可以支持來自多個(gè)主流代碼托管地,可以是本地初始化項(xiàng)目镣衡。
[圖片上傳失敗...(image-942858-1513993971279)]
[圖片上傳失敗...(image-91bac1-1513993971279)]
[圖片上傳失敗...(image-7db04-1513993971279)]

導(dǎo)入成功后,基本上可以看到档悠,所有的github相關(guān)的代碼廊鸥,版本都會(huì)獲取過來。包括社區(qū)全部完整的信息辖所。更多功能參考:https://about.gitlab.com/gitlab-ce-features/

Git GUI

  • Git-scm: https://git-scm.com/downloads

  • SourceTree: https://www.sourcetreeapp.com/

    • SourceTree 是 Windows 和Mac OS X 下免費(fèi)的 Git 和 Hg 客戶端惰说,擁有可視化界面,容易上手操作奴烙。同時(shí)它也是Mercurial和Subversion版本控制系統(tǒng)工具助被。支持創(chuàng)建剖张、提交切诀、clone揩环、push、pull 和merge等操作幅虑。

Markdown format document

For windows:

For Mac:

FAQ

  • I. 如果提示:“You won't be able to pull or push project code via SSH until you add an SSH key to your profile Don't show again | Remind later”
    解決:需要本地配置.ssh免密碼登錄丰滑,可以通過ssh隧道git clone項(xiàng)目,效率會(huì)高得多倒庵。

  • II. Gitlab 項(xiàng)目地址不對(duì)褒墨,希望是自己的域名地址,如:“git@gitlab.example.com:itweet.cn/hadoop.git”,希望是:“git@gitlab.itweet.cn:itweet.cn/hadoop.git

解決:

    [root@gitlab-machine ~]# sudo vim /etc/gitlab/gitlab.rb 
    ## external_url 'http://gitlab.example.com'
    external_url 'http://gitlab.itweet.cn'

    [root@gitlab-machine gitlab]# sudo gitlab-ctl reconfigure

    [root@gitlab-machine ~]# sudo gitlab-ctl restart
  • III. Email發(fā)送郵件失敗

需要發(fā)送郵件的用戶擎宝,比如使用qq發(fā)送郁妈,需要SMTP settings,并且發(fā)郵件用戶開啟smtp/impi功能。

For examples

    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
    gitlab_rails['smtp_port'] = 465
    gitlab_rails['smtp_user_name'] = "xxxx@xx.com"
    gitlab_rails['smtp_password'] = "password"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_ssl'] = true
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = false

參考:https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/configuration.md#configuring-the-external-url-for-gitlab
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md#smtp-on-localhost
http://itweet.github.io/2015/07/12/git-manual/
https://help.github.com/desktop/guides/getting-started/

原創(chuàng)文章绍申,轉(zhuǎn)載請(qǐng)注明: 轉(zhuǎn)載自Itweet的博客
本博客的文章集合: http://www.itweet.cn/blog/archive/

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末噩咪,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子极阅,更是在濱河造成了極大的恐慌胃碾,老刑警劉巖,帶你破解...
    沈念sama閱讀 218,755評(píng)論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件筋搏,死亡現(xiàn)場(chǎng)離奇詭異仆百,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)奔脐,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,305評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門俄周,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人髓迎,你說我怎么就攤上這事栈源。” “怎么了竖般?”我有些...
    開封第一講書人閱讀 165,138評(píng)論 0 355
  • 文/不壞的土叔 我叫張陵甚垦,是天一觀的道長。 經(jīng)常有香客問我涣雕,道長艰亮,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,791評(píng)論 1 295
  • 正文 為了忘掉前任挣郭,我火速辦了婚禮迄埃,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘兑障。我一直安慰自己侄非,他們只是感情好蕉汪,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,794評(píng)論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著逞怨,像睡著了一般者疤。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上叠赦,一...
    開封第一講書人閱讀 51,631評(píng)論 1 305
  • 那天驹马,我揣著相機(jī)與錄音,去河邊找鬼除秀。 笑死糯累,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的册踩。 我是一名探鬼主播泳姐,決...
    沈念sama閱讀 40,362評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼暂吉!你這毒婦竟也來了胖秒?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,264評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤借笙,失蹤者是張志新(化名)和其女友劉穎扒怖,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體业稼,經(jīng)...
    沈念sama閱讀 45,724評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡盗痒,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,900評(píng)論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了低散。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片俯邓。...
    茶點(diǎn)故事閱讀 40,040評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖熔号,靈堂內(nèi)的尸體忽然破棺而出稽鞭,到底是詐尸還是另有隱情,我是刑警寧澤引镊,帶...
    沈念sama閱讀 35,742評(píng)論 5 346
  • 正文 年R本政府宣布朦蕴,位于F島的核電站,受9級(jí)特大地震影響弟头,放射性物質(zhì)發(fā)生泄漏吩抓。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,364評(píng)論 3 330
  • 文/蒙蒙 一赴恨、第九天 我趴在偏房一處隱蔽的房頂上張望疹娶。 院中可真熱鬧,春花似錦伦连、人聲如沸雨饺。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,944評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽额港。三九已至饺窿,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間锹安,已是汗流浹背短荐。 一陣腳步聲響...
    開封第一講書人閱讀 33,060評(píng)論 1 270
  • 我被黑心中介騙來泰國打工倚舀, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留叹哭,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,247評(píng)論 3 371
  • 正文 我出身青樓痕貌,卻偏偏與公主長得像风罩,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子舵稠,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,979評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理超升,服務(wù)發(fā)現(xiàn),斷路器哺徊,智...
    卡卡羅2017閱讀 134,659評(píng)論 18 139
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的閱讀 13,478評(píng)論 5 6
  • Awesome Ruby Toolbox Awesome A collection of awesome Ruby...
    debbbbie閱讀 2,875評(píng)論 0 3
  • 嗯室琢,這還得從初一開始說起, 那個(gè)時(shí)候落追,見她第一面的時(shí)候盈滴,天是藍(lán)藍(lán)的,我們剛剛成長了一點(diǎn)點(diǎn)轿钠。要說我倆認(rèn)識(shí)的原因巢钓,歸咎...
    之乎者微閱讀 145評(píng)論 0 0
  • 今天下班回家,927里今天互動(dòng)的話題是2016年你還沒有實(shí)現(xiàn)的愿望是什么疗垛?有人說還沒脫單症汹,有人說還沒脫貧,還有各種...
    baby_521閱讀 175評(píng)論 0 0