Linux-Gitllab安装

安装Gitllab(默认端口:80)

安装包下载

个人收集

wget http://cunqi0105-1300757323.cos.ap-shanghai.myqcloud.com/install-pkg/gitlab-ce-12.10.9-ce.0.el7.x86_64.rpm

官方下载

https://mirrors.tuna.tsinghua.edu.cn/

image-20200706151449142

image-20200706151528135

image-20200706151548079

rpm -ivh gitlab-ce-12.10.9-ce.0.el7.x86_64.rpm 

image-20200706151700754

基础配置

systemctl stop firewalld && setenforce 0 

yum clean all && yum makecache && yum install -y curl policycoreutils-python openssh-server vim wget

systemctl enable sshd && systemctl start sshd

修改配置文件

vim /etc/gitlab/gitlab.rb

external_url 'http://localhost:7990'
nginx['listen_port'] = 7990

image-20200706151816595

<!--默认nginx 监听的是80 端口,如果nginx 修改端口,external_url 里面也必须带端口-->

启动gitlab

启动gitlab:
gitlab-ctl reconfigure && gitlab-ctl start
查看主件信息:
gitlab-ctl status
开机自启:
systemctl enable gitlab-runsvdir.service
systemctl start gitlab-runsvdir.service

image-20200706152311447

创建管理员用户密码

image-20200706160009837

image-20200706160033705

gitlab常用命令

gitlab-ctl start #启动全部服务
gitlab-ctl restart #重启全部服务
gitlab-ctl stop #停止全部服务
gitlab-ctl restart nginx #重启单个服务
gitlab-ctl status #查看全部组件的状态
gitlab-ctl show-config #验证配置文件
gitlab-ctl uninstall #删除gitlab(保留数据)
gitlab-ctl cleanse #删除所有数据,重新开始
gitlab-ctl tail <svc_name>  #查看服务的日志
gitlab-rails console production #进入控制台 ,可以修改root 的密码

卸载gitlab

使用gitlab 自带工具将数据全部清空

gitlab-ctl cleanse 

image-20200706160337559

停止gitlab

gitlab-ctl stop

卸载gitlab(注意这里写的是gitlab-ce)

rpm -e gitlab-ce

查看gitlab进程

ps aux | grep gitlab

杀掉第一个进程(就是带有好多.............的进程)

kill -9 18777

删除所有包含gitlab文件

find / -name gitlab | xargs rm -rf

gitlab内nginx配置反向代理

修改nginx配置文件

vim /opt/gitlab/embedded/conf/nginx.conf
#Gitlab代码库反向代理
  server {
      listen       80;
      server_name  git.test.com;
      location / {
          proxy_pass http://127.0.0.1:7990;
  proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For
   $proxy_add_x_forwarded_for;
      }
  }

重新加载nginx配置文件

/opt/gitlab/embedded/sbin/nginx  -s reload 

注意

如果在nginx添加反向代理需要在http字段,添加client_max_body_size 200M;该字段,以免造成代码过大上传失败

    client_max_body_size 200M;

修改Gitlab上git服务器地址

image-20201112141600886

修改 gitlab.yml 文件

vim /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

image-20201112140043863

重启gitlab服务器

gitlab-ctl restart

上传代码文件过大,导致上传失败

修改nginx配置文件

如果在nginx添加反向代理需要在http字段,需要添加该字段,以免造成代码过大上传失败

client_max_body_size 200M;

/opt/gitlab/embedded/sbin/nginx  -s reload

修改gitlab限制

image-20201112141627548

 

posted @ 2020-07-22 16:40  孤独的小人物  阅读(185)  评论(0编辑  收藏  举报