CentOS安装GitLab

开发者福利!热门AI工具限时免费用 购周边即赠Coding Plan Lite,Claude Code、Cursor等20+工具畅享,效率翻倍! 阅读详情

环境

Requirements
软件 版本
CentOS 6.6
Python 2.6
Ruby 2.1.5
Git 1.7.10+
Redis 2.0+
MySQL  
GitLab 7-8-stable
GitLab Shell v2.6.0
yum源

为了提高软件安装速度,将yum源设置为阿里云开源镜像

$ cd /etc/yum.repos.d
$ wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
必要软件包
$ yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker

安装Git

// 查看当前git版本
$ git --version

// 如果小于1.7.10则先卸载
$ yum remove git

// 下载最新的git并安装
$ wget -O git-src.zip https://github.com/git/git/archive/master.zip
$ unzip git-src.zip
$ cd git-src
$ make prefix=/usr/local all
$ make prefix=/usr/local install
$ ln -fs /usr/local/bin/git* /usr/bin/

安装Ruby环境

$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl --progress ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz | tar xz
$ cd ruby-2.1.5
$ ./configure --disable-install-rdoc
$ make && make install

$ ln -s /usr/local/bin/ruby /usr/bin/ruby
$ ln -s /usr/local/bin/gem /usr/bin/gem
$ ln -s /usr/local/bin/bundle /usr/bin/bundle

// 设置ruby gem源为淘宝
$ gem source -r https://rubygems.org/
$ gem source -a http://ruby.taobao.org/

$ gem install bundler --no-ri --no-rdoc

安装MySQL及初始化GitLab库

$ yum install mysql mysql-devel mysql-server -y
$ /etc/init.d/mysqld start
$ chkconfig mysqld on

// 登录mysql创建gitab的帐号和数据库
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';

//测试是否可以用git帐号登录数据库
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production

安装Redis

$ yum -y install redis
$ /etc/init.d/redis start
$ chkconfig redis on

添加git帐号并允许sudo

$ useradd --comment 'GitLab' git
$ echo "git ALL=(ALL)       NOPASSWD: ALL" >>/etc/sudoers

安装GitLab

$ /home/git
$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab
$ cd /home/git/gitlab
$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

// 编辑git路径, gitlab的host:port
$ vim config/gitlab.yml
// bin_path: /usr/local/bin/git
// host: localhost
// port: 80 

// 给文件夹添加相应的权限
$ chown -R git log/
$ chown -R git tmp/
$ chmod -R u+rwX  log/
$ chmod -R u+rwX  tmp/

// 创建必要的文件夹,以及复制配置文件
$ sudo -u git -H mkdir /home/git/gitlab-satellites
$ sudo -u git -H mkdir tmp/pids/
$ sudo -u git -H mkdir tmp/sockets/
$ sudo chmod -R u+rwX  tmp/pids/
$ sudo chmod -R u+rwX  tmp/sockets/
$ sudo -u git -H mkdir public/uploads
$ sudo chmod -R u+rwX  public/uploads
$ sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
$ sudo -u git -H cp config/initializers/rack_attack.rb.example
 config/initializers/rack_attack.rb

// 配置数据库连接信息
$ sudo -u git cp config/database.yml.mysql config/database.yml
$ sudo -u git -H vim  config/database.yml
$ vim config/database.yml
// production:
//     username: gitlab
//     password: "gitlab"

安装GitLab-Shell

$ cd /home/git
$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.6.0
$ cd gitlab-shell/
$ sudo -u git -H cp config.yml.example config.yml

// 编辑配置文件, 设置gitlab_url, redis-cli, log-level...
$ vim config.yml
// gitlab_url: "http://localhost/"
// /usr/bin/redis-cli

// 安装git-shell
$ sudo -u git -H ./bin/install

安装需要ruby的gems

$ cd /home/git/gitlab
$ sudo -u git -H bundle install --deployment --without development test postgres aws

初始化数据库(创建GitLab相关表)

$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

安装启动文件以及日志切割文件

cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

设置git帐号信息

$ sudo -u git -H git config --global user.name "Troy Zhang"
$ sudo -u git -H git config --global user.email "troyz@synnex.com"
$ sudo -u git -H git config --global core.autocrlf input

安装Nginx

$ yum -y install nginx
$ vim /etc/nginx/nginx.conf
user              root git;
worker_processes  2;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
# GITLAB
# Maintainer: @randx
# App Version: 5.0

upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
  listen *:80 default_server;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
  server_name YOUR_SERVER_FQDN;     # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;

  # Set value of client_max_body_size to at least the value of git.max_size in gitlab.yml
  client_max_body_size 5m;

  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/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 {
    proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
    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_pass http://gitlab;
  }
}
}

更改权限,启动nginx

$ nginx -t
$ chown -R git:git /var/lib/nginx/
$ /etc/init.d/nginx start

检测当前环境

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

拉取gitlab静态资源文件

$ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

启动gitlab

$ /etc/init.d/gitlab start

检测各个组件是否正常工作

$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
centos8安装gitlab Centos安装gitlab 1.安装依赖(Centos7需要安装此依赖) yum install -y curl policycoreutils-python openssh-server 2.启动ssh并设置为开机自启动 systemctl enable sshd systemctl start sshd 3.添加http服务到firewalld,pemmanent表示永久生效,若不加–permanent系统下次启动后就会失效 systemctl start firewalld firewal 阅读详情

相关推荐

CentOS GitLab安装

GitLab安装 Gitlab下载地址: 国外:gitlab/gitlab-ce - Packages · packages.gitlab.com 国内清华镜像:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/ 关闭centos的防火墙,并设置不在开机启动 systemctl stop firewalld.service systemctl disable firewalld.service 安装依赖软件openssh(ssh

weixin_45144935的博客 1296

centos6搭建gitlab的方法步骤

主要介绍了centos6搭建gitlab的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

CentOS8下安装配置GitLab

一、安装GitLab-ce社区版 1.1 安装依赖关系 [root@GitLab ~]# dnf install policycoreutils openssh-server postfix 1.2 开启SSH并设置开机启动 [root@GitLab ~]# systemctl enable sshd [root@GitLab ~]# systemctl start sshd 1.3 开放系统...

Bksz_guest的博客 3961

CentOS6安装gitlab

1, docker运行gitlab 参考:https://www.jianshu.com/p/080a962c35b6 cat >/usr/local/bin/gitlab.sh<<EOF docker run -d -p 443:443 -p 80:80 -p 222:22 \ --hostname gitlab \ --name gitlab \ --restart...

eyeofeagle的博客 1406

Gitlabcentos6搭建

1 Gitlab服务搭建 1.1 卸载 sudo gitlab-ctl uninstall sudo rpm -e gitlab-ce find / -name gitlab|xargs rm -rf

九天的专栏 3769

CentOS 6安装Gitlab

1. 保证CentOS 6能连接网络 . 2.安装依赖: sudo yum install -y curl policycoreutils-python openssh-server cronie sudo lokkit -s http -s ssh 3.接下来,安装Postfix以发送通知电子邮件。如果要使用其他解决方案发送电子邮件,请跳过此步骤并在安装GitLab后...

weixin_30336061的博客 905

Centos安装gitlab,通俗易懂

2.创建存放gitlab安装包的目录,并将下载好的gitlab安装包放进去。7.gitlab 安装初始化后,默认账户名是root,密码存放在配置文件。直接在浏览器上输入配置文件中的IP就可以了,没有端口。10.更改完重新登陆就可以了!提示以下信息就说明安装成功了。看到上面就说明彻底安装成功了。5.然后执行 生效配置代码。8.访问gitlab

fhj_fhj的博客 2062

Centos6 安装 GItLab

1.镜像下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/,官网下载比较慢所有在这下载 centos 6系统的下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6 centos 7系统的下载地址:https://mirrors.tuna.tsinghua.ed...

u012499506的博客 571

Centos7 安装GitLab

虚拟机:Centos7 最小安装 4核8G本次实验下载的是 gitlab-ce-14.1.0-ce.0.el7.x86_64.rpm 官网截图 清华源截图 安装Postfix用于发送通知邮件,当然也可以使用其他SMTP服务器来发送邮件,本次实验使用Postfix。 安装GitLab安装程序下载并上传至服务器,在安装程序所在目录执行 与在线安装一样出现GitLab图标安装成功 external_url 指的是通过外部的哪个域名访问GitLab。可以写成本机的IP如:http://10.0.0.60 可

趙兴晨的博客 2470

centos7安装gitLab

centos7离线安装gitLab 一、前言 二、相关依赖准备 三、下载 四、安装 在项目开发中都需要代码托管仓库来对开发中的代码进行管理,主流的两大代码托管仓库SVN(subversion)和GitHub。GitHub是很适合的开源项目代码托管,但在很多企业前期开发中需要建立私有仓库来管理代码,所以企业开发用的最多的还是gitLab。二者的区别这里不做过多讲解。感兴趣的朋友可以自己去查阅资料。 需要在服务器上搭建全新Gitlab服务器,完毕后在此记录全过程及遇到的问题。 注:我是在内网防火墙关闭状

weixin_35815479的博客 6839

CentOSGitLab安装部署_centos 安装部署 gitlab

转载来源 :https://mp.weixin.qq.com/s/kUwZja0xK1IfqGU6R2f1EA。

2401_85599444的博客 2582

Centos安装GitLab教程

本文章主要介绍了如何在centos7上安装GitLab,以及安装完成后如何登录和创建第一个工程。

new9232的博客 1890

Centos 9安装GitLab

1. 下载GitLab 下载地址:gitlab/gitlab-ce - Packages · packages.gitlab.com 选择el的最新的发行版 2. 安装GitLab 2.1 将下载的GitLab上传到CentOS服务器中 2.2 编写GitLab安装脚本 vim gitlab-install.sh 将如下代码写入gitlab-install.sh脚本中 sudo dnf install -y curl policycoreutils openssh-server

smilell4的博客 2684

centos7安装部署gitlab

相关教程请参考官网https://doc.gitlab.cc/omnibus/settings/smtp.html。是一个面向开源及私有软件项目的托管平台,因为只支持git作为唯一的版本库格式进行托管,故名GitHub。GitLab拥有与GitHub类似的功能,能够浏览源代码,管理缺陷和注释,可以管理团队对仓库的访问,GitHub如果使用私有仓库,是需要付费的,GitLab可以在上面搭建私人的免费仓库。smtp是默认开启的,两个都启用了,两个都不会工作。发信系统用的默认的postfix,

justlpf的专栏 7951

CentOs7 安装Gitlab

CentOs7 安装Gitlab

weixin_39381034的博客 1565

centos7安装gitlab

转载自:https://www.cnblogs.com/wenwei-blog/p/5861450.html 1. 安装依赖软件 yum -y install policycoreutils-python openssh-server openssh-clients postfix 2.设置postfix开机自启,并启动,postfix支持gitlab发信功能 systemctl en...

FinelyYang的专栏 2605

Centos7安装Gitlab

一、安装依赖 sudo yum install -y curl policycoreutils-python openssh-server sudo systemctl enable sshd sudo systemctl start sshd (防火墙如果关闭不需要) sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=

笑笑是一个码农 1014

Gitlab 8 在 CentOS 安装

参考 centos 6.5安装GitLab全过程和问题记录 gitlab recipes - install gitlab-recipes install on centos gitlab-recipes install on centos - github Installation from source GitLab Community Edition Offi...

weixin_42463677的博客 2012
上一篇: 数据库分库分表(sharding)系列(五) 一种支持自由规划无须数据迁移和修改路由代码的Sharding扩容方案
下一篇: mysql主从复制
静水流深cn
博客等级 码龄20年 56粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值