- 查询系统发行版本,寻找GitLab对应版本
$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
- 安装过程参考《手把手教你 GitLab 的安装及使用》,RHEL/CentOS用户在
rooot权限
下,用yum或下载清华大学镜像源:
- 新建文件 /etc/yum.repos.d/gitlab_gitlab-ce.repo 内容:
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
- 安装依赖
#可忽略。CentOS7 卸载旧git,安装新版git
yum install -y epel-release
rpm -ivh https://centos7.iuscommunity.org/ius-release.rpm
yum list git2u
yum install -y git2u
git --version
sudo yum install curl openssh-server openssh-clients postfix cronie -y
sudo service postfix start
sudo chkconfig postfix on
sudo lokkit -s http -s ssh # 这句用于防火墙,避免用户通过ssh方式和http访问。暂未执行
# 下面是怕redis和nginx没依赖包,提前装了试试
yum -y install gcc
yum install tcl
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel
yum -y install openssl openssl--devel
yum -y install pcre pcre-deve
yum -y install pcre-devel.i686
yum -y install make zlib zlib-devel gcc-c++ libtool
- 安装镜像源
# yum法
rm -f /var/run/yum.pid #若yum锁定
yum list installed | grep gitlab
yum -y remove gitlab-ce.x86_64 #完全卸载删除gitlab https://yq.aliyun.com/articles/114619
yum clean all
sudo yum makecache
sudo yum install gitlab-ce -y
# 下载法 centos7版本用el7文件夹,最新版有问题时手动降级
cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm
chmod 755 gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm
rpm -ivh gitlab-ce-10.7.7-ce.0.el7.x86_64.rpm
# 安装完后,将external_url 'http://gitlab.example.com' 改为自己的域名ip,默认8080端口改为9090
sudo gedit /etc/gitlab/gitlab.rb
---
external_url 'http://192.168.0.210'
unicorn['port'] = 9090
nginx['listen_port'] =8888
---
# 对GitLab进行初始化配置
sudo gitlab-ctl reconfigure
sudo gitlab-ctl reconfigure
初始化需等待一段时间,有卡住不动、依赖关系等大问题就删了重装低版本。有gitlab Reconfigured!
说明成功。
注意:执行 reconfigure 命令会把gitlab的nginx组件的配置还原,导致自定义修改的端口以及域名等没有。所以先初始化,再自定义修改。
- 自定义修改gitlab并启动
#外网访问的端口,默认80改为8888
sudo gedit /var/opt/gitlab/nginx/conf/gitlab-http.conf
---
server {
listen 192.168.0.210:8888;
server_name 192.168.0.210;
---
sudo gedit /var/opt/gitlab/gitlab-rails/etc/unicorn.rb
listen "192.168.0.210:9090", :tcp_nopush => true
#设置项目页面中间http地址
sudo gedit /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
host: 192.168.0.210
port: 8888
#设置项目页面中间ssh地址
sudo gedit /var/opt/gitlab/gitlab-shell/config.yml
# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://192.168.0.210:9090"
#增加端口到防火墙配置中,执行以下操作:
iptables -I INPUT -p tcp --dport 9090 -j ACCEPT
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
iptables -L -n #查看防火墙
netstat -tln #查看端口
#重启gitlab,访问http://192.168.0.210:8888
http://192.168.0.88:8888
gitlab-ctl restart
sudo gitlab-ctl restart sidekiq
sudo gitlab-ctl hup unicorn
gitlab-ctl tail unicorn
访问gitlab,第一次登陆时设置密码
gitlab-ctl start|stop|status|restart #管理
gitlab-ctl restart #重启gitlab
在restart后,就可以直接访问:http://192.168.0.210:8888 ,默认用户名root,第一次登陆时设置密码。
若有502问题,修改冲突的端口,或reboot
重启试试。
502太坑了……gitlab集成了各组件,所以要修改各组件具体的ip地址、端口号。
对于错误,及时查看日志文件和错误文件,如:
gitlab-shell.log
gitlab_access.log
unicorn_stderr.log
gitlab_error.log
一般都是127.0.0.1或端口没改过来,即使gitlab网页已经打开,上传东西时也有可能上传组件地址配错,传不上去。
默认安装的gitlab,主要有四个目录:
/opt/gitlab/ ## 主目录
/etc/gitlab/ ## 放置配置文件
/var/opt/gitlab/ ## 各个组件
/var/log/gitlab/ ## 放置日志文件
检查gitlab各组件状态:
gitlab-ctl status
重启gitlab:
gitlab-ctl restart
只重启某个组件:
gitlab-ctl restart nginx
gitlab组件:
nginx:
postgresql:
redis:
unicorn:
sidekiq:
logrotate:
---------------------
作者:独孤仁
来源:CSDN
原文:https://blog.csdn.net/kong2030/article/details/80282111
gitlab目录结构
5 汉化 #可跳过这步
cd /opt
wget https://gitlab.com/xhang/gitlab/repository/10-7-stable-zh/archive.tar.bz2 -O gitlab-10-7-stable-zh.tar.bz2
tar xf gitlab-10-7-stable-zh.tar.bz2
mv gitlab-10-7-stable-zh-c400d379745573f67a8961f41534bd4653136d8e gitlab-10-7-stable-zh
cat gitlab-10-7-stable-zh/VERSION
sudo gitlab-ctl stop
#先备份,避免汉化失败后gitlab瘫痪
cp -r /opt/gitlab/embedded/service/gitlab-rails{,.ori}
\cp -rf gitlab-10-7-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
忽略以下2个提示
cp: 无法以目录"gitlab-10-7-stable-zh/log" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/log"
cp: 无法以目录"gitlab-10-7-stable-zh/tmp" 来覆盖非目录"/opt/gitlab/embedded/service/gitlab-rails/tmp"
gitlab-ctl reconfigure
sudo gedit /etc/gitlab/gitlab.rb
sudo gedit /var/opt/gitlab/nginx/conf/gitlab-http.conf
gitlab-ctl restart
6 客户端TortoiseGit安装、配置
- Git简介及安装 https://www.cnblogs.com/xiuxingzhe/p/9300905.html
- Git秘钥生成以及Gitlab配置 https://www.cnblogs.com/xiuxingzhe/p/9303278.html
- TortoiseGit安装、配置 https://www.cnblogs.com/xiuxingzhe/p/9312929.html
手把手教你 GitLab 的安装及使用
https://www.jianshu.com/p/b04356e014fa
完全卸载删除gitlab
https://yq.aliyun.com/articles/114619
安装GitLab出现ruby_block[supervise_redis_sleep] action run
https://www.cnblogs.com/springwind2006/p/6872773.html
搭建GitLab并汉化
https://www.jianshu.com/p/2400d9e57fd1
CentOS 7 上 GitLab 的安装、备份、迁移及恢复
https://www.ifeegoo.com/the-installation-backup-migration-restore-of-gitlab-on-centos-7.html
我所遇到的GitLab 502问题的解决
https://blog.csdn.net/wangxicoding/article/details/43738137
Ubuntu 14.04下安装GitLab指南
https://www.cnblogs.com/duyinqiang/p/5696435.html
网友评论