GitLab之安装-yellowcong

GitLab 安装和GitLab的汉化操作,可以简单的搭建GitLab和端口的修改,GitLab的端口修改真TMD的烦人,端口改了之后,不一定好用,需要重启服务,需要停止GitLab, 然后重启GitLab,就可以了,还有安装方式建议使用RPM的安装方式,命令行的方式,是真麻烦,还不好用。

镜像地址

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/?C=M&O=A

1.安装配置依赖项

sudo yum install curl openssh-server openssh-clients postfix cronie -y
sudo service postfix start
sudo chkconfig postfix on

2.1 RPM包安装方式(推荐)

#安装
wget http://yellowcong.qiniudn.com/gitlab-ce-8.17.0-ce.0.el7.x86_64.rpm

#安装rpm
rpm -i gitlab-ce-8.17.0-ce.0.el7.x86_64.rpm

#配置
gitlab-ctl reconfigure

还有一种,更牛逼的方式,一句话,

#安装gitlab
yum install -y gitlab-ee

#配置gitlab
gitlab-ctl reconfigure

2.命令行安装方式(不推荐)

2.1手动添加源

#添加源
vi /etc/yum.repos.d/gitlab-ce.repo

#设定源的类容,有些源不好用,就得自己找了,这是通过自动导入源工具,导入的,好用
[gitlab_gitlab-ce]
name=gitlab_gitlab-ce
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/$basearch
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[gitlab_gitlab-ce-source]
name=gitlab_gitlab-ce-source
baseurl=https://packages.gitlab.com/gitlab/gitlab-ce/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ce/gpgkey/gitlab-gitlab-ce-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300


#建立安装包索引缓存
yum makecache

gitlab-ce里面的源配置文件

这里写图片描述

2.2自动添加源

如果手动添加了源,就不需要curl 来自动添加源的操作了,这个如果自动添加后,在/etc/yum.repos.d配置文件中,添加了源文件 gitlab-ce.repo文件

#添加GitLab的仓库
curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash

#上面如果找不到文件,就用下面的吧
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash

这里写图片描述

2.3安装gitlabe

gitlab最新版本有汉化的,但是汉化不全,所以我建议安装gitlab8.8版本,有汉化的插件包

#自动安装最新版,最新版本,可能没有汉化
sudo yum install gitlab-ce

#安装指定版本 ,安装8.17.0,这样好汉化操作
sudo yum install gitlab-ce-8.17.0

#源码汉化所在包是8.8版本的,所以我们需要安装8.8版本的
git clone https://gitlab.com/xhang/gitlab.git
注:原来的https://gitlab.com/larryli/gitlab.git作者已经停止维护,停留在8.8版本

安装完成后,出现下面的GITlab的log,说实话挺有意思的

这里写图片描述

有个小问题,gitlab有可能没安装上

安装失败,命令没有执行,解决办法是,找到rpm的安装包,手动执行安装。说实话,这种通过命令安装的方式真的很费劲啊,还不如直接获取到 rpm安装包,然后直接手动执行安装命令

这里写图片描述

#找到yum的配置文件,查看配置文件,看我们的安装包下载到了哪个地方
cat /etc/yum.conf

#安装rpm
rpm -i gitlab-ce-8.17.0-ce.0.el7.x86_64.rpm

yum安装的目录所在包
这里写图片描述

查找到目录所在的包目录,然后rpm -i gitlab-ce-8.17.0-ce.0.el7.x86_64.rpm来安装gitlab
这里写图片描述

3.修改下配置文件

当我们修改完配置文件,或者是第一次启动,需要运行这个配置命令,这个地方会耗时很长,大约1-10分钟,看电脑内存大小

gitlab-ctl reconfigure

这里写图片描述

配置成功,如果报错,这个地方就会显示

这里写图片描述

4.启动GitLab

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        # 查看日志;

这里写图片描述

登录

这里写图片描述

5.GitLab 端口修改

配置文件目录 /opt/gitlab/etc,默认情况下,会使用80端口,每次重新配置,都需要执行sudo gitlab-ctl reconfigure 使之生效。

GitLab Workhorse是一个敏捷的反向代理。它会处理一些大的HTTP请求,比如文件上传、文件下载、Git push/pull和Git包下载。其它请求会反向代理到GitLab Rails应用,即反向代理给后端的unicorn。

修改unicorn配置(这个可以不用配置,默认是8080端口)

配置文件在/opt/gitlab/etc/gitlab.rb。这个文件用于gitlab如何调用80和8080的服务等。
1、配置文件/etc/gitlab/gitlab.rb

vim /etc/gitlab/gitlab.rb
#修改端口号
#unicorn['port'] = 8080 #原来配置
unicorn['port'] = 9091

gitlab-rails修改(这个可以不用配置,默认是8080端口),这个修改的是unicorn的端口

2、配置文件/var/opt/gitlab/gitlab-rails/etc/unicorn.rb

vim /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

#修改端口和域名
#listen "127.0.0.1:8080", :tcp_nopush => true #原配置

#这个端口号码,需要和/opt/gitlab/etc/gitlab.rb 里面配置一致
listen "127.0.0.1:9091", :tcp_nopush => true

#配置生效
gitlab-ctl reconfigure

#重启服务
gitlab-ctl restart 

gitlab nginx 修改

配置文件 /var/opt/gitlab/nginx/conf/gitlab-http.conf。这个文件是gitlab内置的nginx的配置文件,里面可以影响到nginx真实监听端口号。

1、修改 /etc/gitlab/gitlab.rb

#设定开放的端口
vim /etc/gitlab/gitlab.rb
nginx['listen_port'] = 8050

#默认值即80端口 
#nginx['listen_port'] = nil

#设定监听,修改成*,这个我没有写,折腾了老久
#pages_nginx['listen_addresses'] = ['*', '[::]'] 修改这个
pages_nginx['listen_addresses'] = ['*']

2、修改/var/opt/gitlab/nginx/conf/gitlab-http.conf

vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

#监听端口号
listen *:8050; #上面配置的端口号

#停止gitlab
gitlab-ctl stop

#配置生效
gitlab-ctl reconfigure

#重启服务
gitlab-ctl restart 

#这时候如果访问还是有问题那么就
gitlab-ctl stop 
gitlab-ctl start #重启就好用了

这里写图片描述

6.开放端口

端口开放后,保存并重启防火墙生效

#开启端口 ,一个是nginx 9090 ,一个是unicorn  9091
iptables -I INPUT -p tcp -m tcp --dport 8050 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 9091 -m state --state NEW,ESTABLISHED -j ACCEPT

#保存配置
service iptables save

#重启生效
service iptables restart

#查看规则链
iptables -L -n

这里写图片描述

7.默认ROOT密码修改

默认安装登录需要重置root密码。可以自己单独设置一个复杂密码后登录。

这里写图片描述

使用root用户登录

这里写图片描述

这里写图片描述

8.GitLab汉化

查看GitLab版本

cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

这里写图片描述

Git要是没有安装,安装git

 yum install git

这里写图片描述

备份/opt/gitlab/embedded/service目录下的gitlab-rails目录,该目录下的内容主要是web应用部分

#下载汉化包
git clone https://git.oschina.net/qiai365/gitlab-L-zh.git

#包含影藏文件
cp -r /opt/gitlab/embedded/service/gitlab-rails{,.ori}

#停止gitlab
gitlab-ctl stop

#拷贝汉化包到gitlab-rails 目录 -r 包含影藏目录, -f遍历粘贴
yes|cp -rf ../gitlab-L-zh/* /opt/gitlab/embedded/service/gitlab-rails/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狂飙的yellowcong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值