安装GitLab服务
1.安装必要依赖
yum install -y curl policycoreutils openssh-server openssh-clients postfix
2.下载安装镜像
#执行安装检查,添加yum源 脚本 curl -sS http://packages.gitlab.com.cn/install/gitlab-ce/script.rpm.sh | bash #执行安装 yum -y install gitlab-ce
3.修改配置项目
配置文件 /etc/gitlab/gitlab.rb
#配置git域名 external_url 'http://git.gitexample.com' #配置路径(注意,配置完成之后,原有项目的路径不会改变,所以请在一开始就设置好) git_data_dirs({ "default" => { "path" => "/home/git-data" } })
配置邮件
###SMTP Config gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "***@***.com" gitlab_rails['smtp_password'] = "***" gitlab_rails['smtp_domain'] = "***.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_tls'] = false ### Email Settings gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'example@example.com' gitlab_rails['gitlab_email_display_name'] = '通知中心' gitlab_rails['gitlab_email_subject_suffix'] = '' ###配置发信人 user['git_user_email'] = "***@***.com"
配置时区
gitlab_rails['time_zone'] = 'Asia/Shanghai'
配置redis
#有2个地方需要配置 (没有特殊要求,可以不配置) #1 : 可以在此处配置redis地址 gitlab_rails['redis_host'] = "127.0.0.1" gitlab_rails['redis_port'] = 6379 gitlab_rails['redis_password'] = 'password' gitlab_rails['redis_database'] = 0 #2 : 在此处配置redis连接 redis['bind'] = '0.0.0.0' # or specify an IP to bind to a single one redis['port'] = 6379 redis['password'] = 'YjHHZoDxXX97vqVnfJv3I5cNzV1QQ0I'
redis_database 配置不为0的时候报错了..不知道什么原因 , 所以建议都配成0
4.配置并启动
默认可以使用
http://git.gitexample.com
http://ip地址
访问
改端口号 : http是nginx服务的,所以直接改nginx配置就行 nginx位置 : /var/opt/gitlab/nginx
gitlab-ctl reconfigure
注意,所有配置的改动,都需要通过reconfigure来重新加载配置
5.管理命令
#启动 gitlab-ctl start #停止 gitlab-ctl stop #重启 gitlab-ctl restart #状态 gitlab-ctl status
6.重置root密码
[root@localhost ~]# gitlab-rails console production Loading production environment (Rails 4.2.8) irb(main):001:0> user = User.where(id: 1).first => #<User id:1 @root> irb(main):002:0> user.password=123456 => 3306835654 irb(main):003:0> user.password_confirmation=123456 => 3306835654 irb(main):004:0> user.save! Enqueued ActionMailer::DeliveryJob (Job ID: cb303e52-ec38-4ee6-9702-b3955336cb6f) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1 => true irb(main):005:0> quit
7.后台错误调试命令
gitlab-ctl tail
可实时看到系统日志