目标服务器环境:CentOs 7
1、安装gitlab及其依赖项
curl -O https://downloads-packages.s3.amazonaws.com/centos-7.0.1406/gitlab-7.5.1_omnibus.5.2.0.ci-1.el7.x86_64.rpm
sudo yum install openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
sudo rpm -i gitlab-7.5.1_omnibus.5.2.0.ci-1.el7.x86_64.rpm
2、启动gitlab
sudo gitlab-ctl reconfigure
sudo firewall-cmd --permanent --add-service=http # open up the firewall for HTTP and SSH requests
sudo systemctl reload firewalld
如果报错
================================================================================
Recipe Compile Error in /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb
================================================================================
RuntimeError
------------
External URL must include a FQDN
Cookbook Trace:
---------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:95:in `parse_external_url'
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:191:in `generate_config'
/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:34:in `from_file'
Relevant File Content:
----------------------
/opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb:
88:
89: def parse_external_url
90: return unless external_url
91:
92: uri = URI(external_url.to_s)
93:
94: unless uri.host
95>> raise "External URL must include a FQDN"
96: end
97: Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
98: Gitlab['gitlab_rails']['gitlab_host'] = uri.host
99: Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
100:
101: case uri.scheme
102: when "http"
103: Gitlab['gitlab_rails']['gitlab_https'] = false
104: when "https"
解决:http://stackoverflow.com/questions/26660084/external-url-must-include-a-fqdn
vim /opt/gitlab/embedded/cookbooks/gitlab/libraries/gitlab.rb
99 def parse_external_url
100 return unless external_url
101
102 uri = URI("http://whatever.example.com")
//just change external_url line here
103
104 unless uri.host
105 raise "External URL must include a FQDN"
106 end
107 Gitlab['user']['git_user_email'] ||= "gitlab@#{uri.host}"
108 Gitlab['gitlab_rails']['gitlab_host'] = uri.host
109 Gitlab['gitlab_rails']['gitlab_email_from'] ||= "gitlab@#{uri.host}"
110
111 case uri.scheme
112 when "http"
113 Gitlab['gitlab_rails']['gitlab_https'] = false
114 when "https"
115 Gitlab['gitlab_rails']['gitlab_https'] = true
116 Gitlab['nginx']['ssl_certificate'] ||= "/etc/gitlab/ssl/#{uri.host}.crt"
117 Gitlab['nginx']['ssl_certificate_key'] ||= "/etc/gitlab/ssl/#{uri.host}.key"
118 else
119 raise "Unsupported external URL scheme: #{uri.scheme}"
120 end
121
122 unless ["", "/"].include?(uri.path)
123 raise "Unsupported external URL path: #{uri.path}"
124 end
125
126 Gitlab['gitlab_rails']['gitlab_port'] = uri.port
127 end
and then do
gitlab-ctr reconfigure
everything is ok!
3、访问:直接输入目标主机的IP地址
4、新建用户
a、用root身份登录并新建一个用户
b、为新用户新建ssh公钥:
cat ~/.ssh/id_rsa.pub (检查是否已经存在公钥,如果有直接用这个公钥,没有的话继续)
ssh-keygen -t rsa -C "$your_email" (这里的your_email填写新建用户时填写的emial)
填写一个存储公钥的文件名,此文件默认当前执行命令的路径下,接下来要求输入的密码填写新建用户时填写的密码
用cat命令找到这个公钥,然后复制填写到指定位置
c、用管理员身份为新建立的用户分配工程(Add member)
5、用新建用户访问gitLab(以Ubuntu终端为例)
git config --global user.name "ty"
git config --global user.email "ty@reton"
(设置当前git参数)
mkdir testGit
cd testGit
git init
(建立并初始化本地仓储)
touch README.md
git add README.md
git commit -m "first commit"
(添加文件和变更注解)
git remote add origin ty@120.xxx.xxx.xxx:root/reton_ddz
git push -u origin master
(向远程主机push)
如果报错
fatal: The remote end hung up unexpectedly
Everything up-to-date
解决:http://stackoverflow.com/questions/15240815/git-fatal-the-remote-end-hung-up-unexpectedly
Run the following command to increase the buffer to 500MB after navigating to the repository:
git config http.postBuffer 524288000
6、在eclipse中使用gitLab
a、新建本地仓储
刚开始工程图标是这样的,在这上面右键->Team->Share Project。勾选Use or create repository in parent folder of project,选择工程根目录,点击Create Repository。这样本地仓储就建立完毕了,可以看到工程根目录下多了一个,并且工程图标变成了。
b、提交更改(每次push之前必须先提交)
工程图标上右键->Team->Commit,可以选择Commit and push,也可以先选择Commit稍后push,这里选择Commit and push
c、push
URI填写(直接copy),协议选择http协议,用户名和密码填写gitLab的登录用户名和密码,其他默认即可。然后
最后finish即可。