搭建GitLab的目的:
方便公司开发管理代码
GitLab实现的功能:
1、关闭了gitlab的注册功能
2、修改了默认端口
3、汉化
0、前期准备
# 环境 Ubuntu 14.04 root@iZ2334prw6jZ:~# apt-get install openssh-server root@iZ2334prw6jZ:~# apt-get install openssh-client root@iZ2334prw6jZ:~# apt-get install git
1、安装
root@iZ2334prw6jZ:~# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/ubuntu/pool/trusty/main/g/gitlab-ce/gitlab-ce_8.8.0-ce.0_amd64.deb root@iZ2334prw6jZ:~# dpkg -i gitlab-ce_8.8.0-ce.0_amd64.deb
2、修改配置文件
root@iZ2334prw6jZ:~# vim /etc/gitlab/gitlab.rb external_url 'http://X.X.X.X:8088' ...... gitlab_rails['time_zone'] = 'Asia/Shanghai' gitlab_rails['gitlab_email_from'] = 'xxxxxx@163.com' ...... gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.163.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "xxxxxx@163.com" gitlab_rails['smtp_password'] = "111111" # 客户端授权密码 gitlab_rails['smtp_domain'] = "163.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true ...... user["git_user_email"] = "xxxxxx@163.com" ..... unicorn['listen'] = '127.0.0.1' unicorn['port'] = 8080 #配置文件默认为8080,若其他程序使用了8080端口,需要修为其他端口,否则网页报错502 # 只要修改配置文件就要reconfigure root@iZ2334prw6jZ:~# gitlab-ctl reconfigure
root@iZ2334prw6jZ:~# gitlab-ctl status run: gitlab-workhorse: (pid 8160) 17578s; run: log: (pid 7476) 17625s run: logrotate: (pid 3777) 3220s; run: log: (pid 7521) 17621s run: nginx: (pid 24024) 11294s; run: log: (pid 7487) 17623s run: postgresql: (pid 7218) 17650s; run: log: (pid 7217) 17650s run: redis: (pid 7084) 17656s; run: log: (pid 7083) 17656s run: sidekiq: (pid 22511) 11383s; run: log: (pid 7464) 17627s run: unicorn: (pid 13402) 10110s; run: log: (pid 7424) 17633s
root@iZ2334prw6jZ:~# netstat -anlt | grep 808 tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:8089 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
#其中8089是unicore端口,因主机8080端口已被其他程序使用
3、访问web页面
- 有时出现502,可以刷新网页或者再次reconfigure
- 有时需要sudo gitlab-ctl restart nginx
- 初次访问Web页面会强制让你改密码,初始用户名/密码:root/5iveL!fe
- 禁止前台注册
登录后:右上角 Admin Area --> Settings --> Sign-in Restrictions
然后保存
- 修改admin的邮箱
Admin Area --> Users --> Edit 然后保存
4、汉化
# 首先检查版本 root@iZ2334prw6jZ:~# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 8.8.0 root@iZ2334prw6jZ:~# git clone https://gitlab.com/larryli/gitlab.git root@iZ2334prw6jZ:~# cd gitlab/ # 比较8-8-stable(英文)和8-8-zh(汉化后)的区别然后导出为补丁 root@iZ2334prw6jZ:~# git diff origin/8-8-stable origin/8-8-zh > /tmp/8.8.diff
# 停止 gitlab
root@iZ2334prw6jZ:~# gitlab-ctl stop
# 应用补丁 root@iZ2334prw6jZ:~# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/8.8.diff
root@iZ2334prw6jZ:~# gitlab-ctl start