GitLab的安装及使用教程

GitLab 社区版 8.8.5

https://gitlab.com/xhang/gitlab GitLab 中文社区版

/etc/gitlab/gitlab.rb          #gitlab配置文件
/opt/gitlab                    #gitlab的程序安装目录
/var/opt/gitlab                #gitlab目录数据目录
/var/opt/gitlab/git-data       #存放仓库数据
gitlab-ctl reconfigure         #重新加载配置
gitlab-ctl status              #查看当前gitlab所有服务运行状态
gitlab-ctl stop                #停止gitlab服务
gitlab-ctl stop nginx          #单独停止某个服务
gitlab-ctl tail                #查看所有服务的日志

Gitlab的服务构成:
nginx:                 静态web服务器
gitlab-workhorse        轻量级反向代理服务器
logrotate              日志文件管理工具
postgresql             数据库
redis                  缓存数据库
sidekiq                用于在后台执行队列任务(异步执行)
sudo yum install gitlab-ce-8.8.5

https://www.cnblogs.com/niuben/p/10867877.html GitLab的安装及使用教程

gitlab的配置

配置文件位置 /etc/gitlab/gitlab.rb

[root@centos7 test]# vim /etc/gitlab/gitlab.rb

[root@centos7 test]# grep "^[a-Z]" /etc/gitlab/gitlab.rb

external_url 'http://10.0.0.51'  # 这里一定要加上http://

# 配置邮件服务
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "hgzerowzh@qq.com"  # 自己的qq邮箱账号
gitlab_rails['smtp_password'] = "xxx"  # 开通smtp时返回的授权码
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"   
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['gitlab_email_from'] = "hgzerowzh@qq.com"  # 指定发送邮件的邮箱地址
user["git_user_email"] = "shit@qq.com"   # 指定接收邮件的邮箱地址

修改好配置文件后,要使用 gitlab-ctl reconfigure 命令重载一下配置文件,否则不生效。

gitlab-ctl reconfigure # 重载配置文件

Gitlab常用命令

gitlab-ctl start         # 启动所有 gitlab 组件
gitlab-ctl stop          # 停止所有 gitlab 组件
gitlab-ctl restart       # 重启所有 gitlab 组件
gitlab-ctl status        # 查看服务状态

gitlab-ctl reconfigure   # 启动服务
gitlab-ctl show-config   # 验证配置文件

gitlab-ctl tail          # 查看日志

gitlab-rake gitlab:check SANITIZE=true --trace    # 检查gitlab

 vim /etc/gitlab/gitlab.rb # 修改默认的配置文件

修改gitlab默认端口

gitlab默认需要使用80 8080 等端口,我的centos上有使用这些端口的其他软件;所以必须更改。

步骤如下:

1. 修改 gitlab.yml

进入目录: /var/opt/gitlab/gitlab-rails/etc

将gitlab.yml 中的host和port修改成自己需要的

production: &base
  #
  # 1. GitLab app settings
  # ==========================

  ## GitLab settings
  gitlab:
    ## Web server settings (note: host is the FQDN, do not include http://)
    #host: gitlab.example.com
    #port: 80
    host: IP地址或者域名
    port: 设定端口号1,如8000

    https: false

这里的端口号1 与nginx(gitlab自带的nginx,见下面2)监听的端口号 要相同,这是提供给外部浏览器访问的端口。

2. 修改 gitlab nginx配置

找到 /var/opt/gitlab/nginx/conf/gitlab-http.conf

它是gitlab内置的nginx的配置文件,里面可以影响到nginx真实监听端口号。要与上面的端口号1设置成一样。(位置略靠下)

server {
  #listen *:80;
  listen *: 8000;

3. 修改 unicorn.rb

此文件所在目录与gitlab.yml相同: /var/opt/gitlab/gitlab-rails/etc/unicorn.rb

# What ports/sockets to listen on, and what options for them.
#listen "127.0.0.1:8080", :tcp_nopush => true
listen "127.0.0.1:端口号2,如9080", :tcp_nopush => true

这里的端口号2 是gitlab-rails本身的端口号,gitlab-rails是gitlab内部的后台服务。

4. giltab-shell修改

进入目录:/var/opt/gitlab/gitlab-shell

修改:config.yml

# Url to gitlab instance. Used for api calls. Should end with a slash.
#gitlab_url: "http://127.0.0.1:8080"
gitlab_url: "http://127.0.0.1:9080"

这里设置成端口号2即可。

5. 重启gitlab

以上修改完成后,重启下,就可以访问8000端口的gitlab了。

gitlab-ctl restart
原文地址:https://www.cnblogs.com/caibaotimes/p/15689240.html