更换yum源,更新软件包
# 备份本地yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak
# 获取阿里yum源配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 更新cache
yum makecache
yum -y update
# 安装gcc等
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
yum -y install wget httpd-tools vim
开始安装gitlab
安装必要的依赖
sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
# 也可以直接关闭防火墙
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld
安装Postfix来发送邮件通知
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
添加GitLab镜像源并安装,需要root用户或root权限
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
# EXTERNAL_URL可以安装好后,在vim /etc/gitlab/gitlab.rb中修改
sudo EXTERNAL_URL="域名/ip:port" yum install -y gitlab-ee
gitlab常用命令
gitlab-ctl start # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
vim /etc/gitlab/gitlab.rb # 修改gitlab配置文件;
gitlab-ctl reconfigure # 重新编译gitlab的配置;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;
gitlab-ctl tail nginx/gitlab_access.log
gitlab-ctl help # 查看相关的帮助
此时已经可以访问gitlab的服务了,依据自己机器的情况可以做一些其他的配置
GitLab配置文件修改
gitlab自带的nginx的配置
vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
# 外网访问的端口,如果服务器已经有服务器占用了80,那么这里可以改成其它
listen *:8888;
server_name gitlab.test.domain.com;
set $http_host_with_default "gitlab.test.domain.com:8888";
gitlab基本配置:
#外部访问url(经过编译后,自动将这个配置编译到nginx配置,nginx就无需配置了)
external_url 'http://gitlab.test.domain.com:8888'
#默认值就是8080。如果端口被占用,可将8080修改为其它(例如:9090)
unicorn['port'] = 8080
gitlab发送邮件配置
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = “smtp.exmail.qq.com”
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = “adminstrator@domain.com“
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_authentication']= “plain"
gitlab_rails['smtp_enable_starttls_auto']= true
gitlab_rails['gitlab_email_from']= 'adminstrator@domain.com'
gitlab_rails['gitlab_email_reply_to']= ‘noreply@domain.com'
服务器修改过ssh端口的坑(需要修改配置ssh端口)
#修改过ssh端口,gitlab中项目的的ssh地址,会在前面加上协议头和端口号“ssh://git@gitlab.domain.com:55725/huangdc/test.git”
gitlab_rails['gitlab_shell_ssh_port'] = 55725
配置生效
#使配置生效
gitlab-ctl reconfigure
#重新启动GitLab
gitlab-ctl restart
查看gitlab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
更换gitlab服务器ip的地址
cd /opt/gitlab/embedded/service/gitlab-rails/config
vim gitlab.yml
# 依据自己的情况,更换地址,该地址影响项目代码的地址
gitlab:
## Web server settings (note: host is the FQDN, do not include http://)
#host: 192.168.13.42
#port: 9988
host: gitlab.test.com
port: 80
https: false
# 重启gitlab
gitlab-ctl restart
GitLab的汉化
先查看gitlab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
11.3.4-ee
下载中文补丁包
wget https://gitlab.com/xhang/gitlab/-/archive/11-3-stable-zh/gitlab-11-3-stable-zh.tar.gz
解压
tar -zxvf gitlab-11-3-stable-zh.tar.gz
# # 查看汉化包的版本
cat gitlab-11-3-stable-zh/VERSION
停止gitlab
gitlab-ctl stop
备份
cp -r /opt/gitlab/embedded/service/gitlab-rails{,.ori}
进行汉化
/bin/cp -rf gitlab-11-3-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/
# 报错不用管
重启
# 重新配置gitlab
gitlab-ctl reconfigure
# 重启启动gitlab
gitlab-ctl restart
网友评论