time 20191203
author Venki
vim /etc/yum.repos.d/gitlab-ce.repo
# 将以下内容复制进去
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
yum makecache
# 自动安装最新版
yum install gitlab-ce
# 安装指定版本
yum install gitlab-ce-x.x.x
# 第一次初始化时间较久,大概4-5min
gitlab-ctl reconfigure
如果服务器上面没有部署其他web服务器,那么直接输入服务器IP地址即可进行访问,但是因为我的服务器上面已经部署了Nginx,所以,我是首先停掉Nginx然后在进行访问,测试成功,那么接下来,我要做的就是如何将gitlab默认的服务器更换成我配置的服务器
回到顶部
暂时不进行汉化,英文版的比较好,毕竟是一名程序员,使用原生态的。
回到顶部
# 直接在Windowshosts文件中配置如下即可 cms(code management system)
192.168.1.243 gd.cms.com
# 浏览器输入域名即可解析
vi /etc/gitlab/gitlab.rb
# 将nginx['enable'] = false 并打开注释,大概在1072行
vi /etc/gitlab/gitlab.rb
# 更改external_url 'http://gd.cms.com'即可
# gitlab原来的Nginx配置文件
cd /var/opt/gitlab/nginx/conf
# gitlab-http.conf就是默认的配置文件
# 将上述文件复制到/usr/local/nginx/conf/vhost/ 但是可能会存在问题,要不删除一些,要不直接copy下面的文件内容
upstream gitlab {
# 此处需要根据具体位置更改
server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}
server {
server_name gd.cms.com; # 请修改为你的域名
server_tokens off; # don't show the version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
# Increase this if you want to upload large attachments
# Or if you want to accept large git objects over http
client_max_body_size 250m;
# individual nginx logs for this gitlab vhost
access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
# Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
# WARNING: If you are using relative urls do remove the block below
# See config/application.rb under "Relative url support" for the list of
# other files that need to be changed for relative url support
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
# gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
# 坚持Nginx配置是否正确
/usr/local/nginx/sbin/nginx -t
# 重启gitlab服务和Nginx服务
gitlab-ctl reconfigure
service nginx restart
因为停掉了原来gitlab自带的Nginx服务,所以在此初始化gitlab时,将无法访问的,查看Nginx进程,没有启动,那么此时启动Nginx即可!紧接着访问域名即可访问!
回到顶部
# git-bash执行,会在C:\Users\MyPC\.ssh生成秘钥对,将公钥上传至gitlab即可
ssh-keygen -t rsa -C "[email protected]"
只要将自己的ssh公钥上传至gitlab,那么每次git clone的时候都可以免密拉取代码,但是克隆地址是ssh对应的。而且可以拉取到所有权限仓库的代码。
# 清空git账号密码重新输入
git config --system --unset credential.helper
# 查看当前用户(global)配置
git config --global --list
# 查看当前仓库配置信息
git config --local --list
Linux下面配置git连接ssh(免密那种,主要用于walle自动化部署)
用户组以及用户配置
git config --global user.name '管理员'
git config --global user.email '[email protected]'
回到顶部
# 查看操作系统版本
cat /etc/issue
# 或
cat /etc/centos-release
# 启动所有 gitlab 组件
gitlab-ctl start
# 停止所有 gitlab 组件
sudo gitlab-ctl stop
# 重启所有 gitlab 组件
sudo gitlab-ctl restart
# 查看服务状态
sudo gitlab-ctl status
# 启动服务
sudo gitlab-ctl reconfigure
# 修改默认的配置文件
sudo vim /etc/gitlab/gitlab.rb
# 检查gitlab
gitlab-rake gitlab:check SANITIZE=true --trace
# 查看日志
sudo gitlab-ctl tail
# 查看git配置项
git config -l
问题原因 点我 阅读
解决方法
ps -ef | grep nginx
root 21556 1 0 17:23 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
www 21557 21556 0 17:23 ? 00:00:00 nginx: worker process
root 21881 9830 0 17:26 pts/2 00:00:00 grep --color=auto nginx
# 查看sockets文件属性 主要是看属组用户
ll /var/opt/gitlab/gitlab-rails/
usermod -a -G gitlab-www www
vim /etc/gitlab/gitlab.rb
web_server['external_users'] = ['www']
gitlab-ctl reconfigure
service nginx restart