千家信息网

centos6搭建gitlab的方法步骤

发表于:2026-10-31 作者:千家信息网编辑
千家信息网最后更新 2026年10月31日,前言原来的项目放在公网的gitlab上,处于安全考虑,在内网搭建一套,有图形界面,可以直接从外网git导入进来,使用了一下觉得挺方便,把安装流程记录下来,参考官网:https://gitlab.com
千家信息网最后更新 2026年10月31日centos6搭建gitlab的方法步骤

前言

原来的项目放在公网的gitlab上,处于安全考虑,在内网搭建一套,有图形界面,可以直接从外网git导入进来,使用了一下觉得挺方便,把安装流程记录下来,参考官网:https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/install/centos 可以直接移步那里看

基本环境安装(git\redis\ruby\mysql...)

yum -y groupinstall 'Development Tools'yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 nodejsyum -y install python-docutilsyum -y install postfixgit --version #安装高于2.7.4的git版本yum -y remove gityum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-develmkdir /tmp/git && cd /tmp/gitcurl --progress https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz | tar xzcd git-2.9.0./configuremakemake prefix=/usr/local installyum remove ruby #安装高于2.1版本的ruby,删除老的mkdir /tmp/ruby && cd /tmp/rubycurl --progress https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.9.tar.gz | tar xzcd ruby-2.1.9./configure --disable-install-rdocmakemake prefix=/usr/local installgem install bundler --no-docyum install redis mysql/Data/apps/mysql/bin/mysqld_safe &/Data/apps/mysql/bin/mysql -urootmysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;mysql> grant all on gitlabhq_production.* to 'git'@'localhost' identified by 'git';

配置redis

vim /etc/redis.conf

unixsocket /var/run/redis/redis.sockunixsocketperm 0770
mkdir -p /var/run/redischown redis:redis /var/run/redischmod 755 /var/run/redis/etc/init.d/redis startusermod -aG redis git

配置gitlab相关

# 下载git,用的国内源。国外的太慢了cd /home/gitsudo -u git -H git clone http://git.oschina.net/qiai365/gitlab-ce gitlabcd /home/git/gitlabsudo -u git -H cp config/gitlab.yml.example config/gitlab.ymlsudo -u git -H editor config/gitlab.yml# 修改成自己的host host: iaasgit1.prod.bj1sudo -u git -H cp config/secrets.yml.example config/secrets.ymlsudo -u git -H chmod 0600 config/secrets.ymlsudo chown -R git log/sudo chown -R git tmp/sudo chmod -R u+rwX,go-w log/sudo chmod -R u+rwX tmp/sudo chmod -R u+rwX tmp/pids/sudo chmod -R u+rwX tmp/sockets/sudo -u git -H mkdir public/uploads/sudo chmod 0700 public/uploadssudo chmod ug+rwX,o-rwx /home/git/repositories/sudo chmod -R u+rwX builds/sudo chmod -R u+rwX shared/artifacts/sudo -u git -H cp config/unicorn.rb.example config/unicorn.rbnprocsudo -u git -H editor config/unicorn.rbsudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rbsudo -u git -H git config --global core.autocrlf inputsudo -u git -H git config --global gc.auto 0sudo -u git -H cp config/resque.yml.example config/resque.ymlsudo -u git -H editor config/resque.yml

配置db部分 only for mysql

sudo -u git cp config/database.yml.mysql config/database.ymlsudo -u git -H editor config/database.yml #配置production部分的password: "密码"sudo -u git -H chmod o-rwx config/database.yml

安装gitlab相关,并启动

# install gemscd /home/git/gitlabsudo -u git -H bundle install --deployment --without development test postgres aws kerberos# install gitlab shellsudo -u git -H bundle exec rake gitlab:shell:install[v3.3.3] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=productionsudo -u git -H editor /home/git/gitlab-shell/config.yml# install gitlab-workhorsecd /home/gitsudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.gitcd gitlab-workhorsesudo -u git -H git checkout v0.7.5sudo -u git -H make# Initialize Database and Activate Advanced Featurescd /home/git/gitlabsudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=productionsudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword GITLAB_ROOT_EMAIL=youremailcp lib/support/init.d/gitlab /etc/init.d/gitlabcp lib/support/init.d/gitlab.default.example /etc/default/gitlabchkconfig gitlab oncp lib/support/logrotate/gitlab /etc/logrotate.d/gitlabsudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=productionsudo -u git -H bundle exec rake assets:precompile RAILS_ENV=productionservice gitlab start

配置nginx

yum install nginxcp lib/support/nginx/gitlab /Data/apps/nginx/conf/include/gitlab.confusermod -a -G git nginxchmod g+rx /home/git//Data/apps/nginx/conf/include/gitlab.conf #把这个配置里的server_name配置好

最后check一下

cd /home/git/gitlabsudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production# 启动gitlab/etc/init.d/gitlab restart# 直接打开server_name对应的url,发现样式都没了,执行sudo -u git -H bundle exec rake assets:clean assets:precompile REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production

最后说明一下

这个只是记一个流水账,里边可能涉及到权限之类的问题,在确保一下nginx\git互相之间是否有权限,另外用check脚本进行check,提示很友好,一般都能搞定,祝你成功。

中间使用的yum由于用的是重写打包过的rpm,路径和默认的不同,如果你用的默认的,可以根据自己情况改一下,或者直接参考官网,我这就是官网的一个根据自己环境的阉割版。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

配置 就是 权限 版本 环境 部分 参考 不同 安全 成功 之间 内容 前言 只是 图形 密码 情况 样式 流水 流水账 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 为想互联网科技怎么样 科技与互联网 互联网巨头科技公司 中国 科技 互联网 互联网与新科技 掌上梦互联网科技 互联网养老 桔豆科技 互联网科技股有哪些 恒银科技与互联网金融 受益于互联网科技的高速发展 速维有品互联网信息科技(苏州)有限公司 特约风豹互联网科技为什么扣费 互联网数据科技专业 滨湖区互联网智能科技产品有哪些 山东星卡互联网科技有限公司官网 中国科技和美国互联网 美国五大互联网科技公司市值多少 北京军民互联网科技公司 长沙易易互联网科技有限公司 恒生科技互联网指数十大成分股 互联网科技公司华为 关于新基建和互联网科技 互联网科技公司官网 广州互联网络科技有限公司 润盈互联网科技 天扬科技互联网广告 互联网与数字科技关系 中国科技和美国互联网 张家口科技产业互联网平台 如何强化互联网金融科技
0