安装gitlab

编写gitlab镜像源

# vim /etc/yum.repos.d/gitlab-ce.repo    # centos7环境
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
# yum install –y makecache

安装gitlab社区版

# yum intall gitlab-ce        #自动安装最新版
# yum install gitlab-ce-x.x.x    #安装指定版本

GitLab常用命令

gitlab-ctl start             # 启动所有 gitlab 组件;
gitlab-ctl stop # 停止所有 gitlab 组件;
gitlab-ctl restart # 重启所有 gitlab 组件;
gitlab-ctl status # 查看服务状态;
gitlab-ctl reconfigure # 启动服务;
vim /etc/gitlab/gitlab.rb # 修改默认的配置文件;
gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;
gitlab-ctl tail # 查看日志;
gitlab-psql gitlabhq_production #gitlab登录数据库
gitlab-rails console #控制台

编辑配置文件

# useradd -s /sbin/nologin -M gitlab
# vim /etc/gitlab/gitlab.rb
external_url 'http://IP:81'
解决端口冲突
unicorn['port'] = 8080 => 8081 # 后端
nginx['listen_port'] = 80 => 81 # nginx
gitlab_rails['redis_port'] = 6379 => 6380 # redis
普通用户运行
user['username'] = "gitlab"
user['group'] = "gitlab"
编辑邮箱(腾讯企业邮箱)
### Email Settings
gitlab_rails['gitlab_email_from'] = '邮箱'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "邮箱"
gitlab_rails['smtp_password'] = "密码或授权码"
gitlab_rails['smtp_domain'] = "后缀"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
user['git_user_email'] = "邮箱"

启动gitlab

# gitlab-ctl reconfigure

错误

Error executing action `run` on resource 'execute[load sysctl conf net.core.somaxconn]'
# chown -R gitlab.gitlab -R /opt/gitlab
# chmod -R gitlab.gitlab -R /var/log/gitlab
# gitlab-ctl reconfigure
一般gitlab问题:端口冲突与权限问题

测试邮件是否正常

# gitlab-rails consol
irb(main):001:0> Notify.test_email(‘XXXX@XXX','Message Subject','message Body').deliver_now

gitlab界面配置

配置中文

Setting => Preferred language 选择简体中文 =>Update profile sttings

创建用户发送邮件

设置 => 注册限制

后期修改域名访问

# vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
10 ## GitLab settings
11 gitlab:
12 ## Web server settings (note: host is the FQDN, do not include http://)
13 host: 112.123.124.125 => wqblogs.com
14 port: 81 => 80
15 https: false
# gitlab-ctl restart