GitLab的安装及使用教程

GitLab 社区版 8.8.5

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

Copy Highlighter-hljs
/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 用于在后台执行队列任务(异步执行)
Copy Highlighter-hljs
sudo yum install gitlab-ce-8.8.5

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

gitlab的配置#

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

Copy Highlighter-hljs
[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 命令重载一下配置文件,否则不生效。

Copy Highlighter-hljs
gitlab-ctl reconfigure # 重载配置文件

Gitlab常用命令

Copy Highlighter-hljs
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修改成自己需要的

Copy Highlighter-hljs
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设置成一样。(位置略靠下)

Copy Highlighter-hljs
server { #listen *:80; listen *: 8000;

3. 修改 unicorn.rb

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

Copy Highlighter-hljs
# 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

Copy Highlighter-hljs
# 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了。

Copy Highlighter-hljs
gitlab-ctl restart
posted @   caibaotimes  阅读(2084)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示
CONTENTS