centos6搭建gitlab的方法步骤

 更新时间:2019年06月13日 10:20:55   作者:三流码农  
这篇文章主要介绍了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 nodejs

yum -y install python-docutils
yum -y install postfix
git --version #安装高于2.7.4的git版本
yum -y remove git
yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
mkdir /tmp/git && cd /tmp/git
curl --progress https://www.kernel.org/pub/software/scm/git/git-2.9.0.tar.gz | tar xz
cd git-2.9.0
./configure
make
make prefix=/usr/local install

yum remove ruby #安装高于2.1版本的ruby,删除老的
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.9.tar.gz | tar xz
cd ruby-2.1.9
./configure --disable-install-rdoc
make
make prefix=/usr/local install
gem install bundler --no-doc
yum install redis mysql
/Data/apps/mysql/bin/mysqld_safe &
/Data/apps/mysql/bin/mysql -uroot
mysql> 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.sock
unixsocketperm 0770
mkdir -p /var/run/redis
chown redis:redis /var/run/redis
chmod 755 /var/run/redis
/etc/init.d/redis start
usermod -aG redis git

配置gitlab相关

# 下载git,用的国内源。国外的太慢了
cd /home/git
sudo -u git -H git clone http://git.oschina.net/qiai365/gitlab-ce gitlab
cd /home/git/gitlab
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo -u git -H editor config/gitlab.yml
# 修改成自己的host host: iaasgit1.prod.bj1
sudo -u git -H cp config/secrets.yml.example config/secrets.yml
sudo -u git -H chmod 0600 config/secrets.yml
sudo 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/uploads
sudo 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.rb
nproc
sudo -u git -H editor config/unicorn.rb
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
sudo -u git -H git config --global core.autocrlf input
sudo -u git -H git config --global gc.auto 0
sudo -u git -H cp config/resque.yml.example config/resque.yml
sudo -u git -H editor config/resque.yml

配置db部分 only for mysql

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

安装gitlab相关,并启动

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

# install gitlab shell
sudo -u git -H bundle exec rake gitlab:shell:install[v3.3.3] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
sudo -u git -H editor /home/git/gitlab-shell/config.yml

# install gitlab-workhorse
cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
cd gitlab-workhorse
sudo -u git -H git checkout v0.7.5
sudo -u git -H make

# Initialize Database and Activate Advanced Features
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=yourpassword GITLAB_ROOT_EMAIL=youremail
cp lib/support/init.d/gitlab /etc/init.d/gitlab
cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
chkconfig gitlab on
cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
service gitlab start

配置nginx

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

最后check一下

cd /home/git/gitlab
sudo -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,路径和默认的不同,如果你用的默认的,可以根据自己情况改一下,或者直接参考官网,我这就是官网的一个根据自己环境的阉割版。

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

相关文章

  • Mac OS X中设置VIM语法高亮的方法

    Mac OS X中设置VIM语法高亮的方法

    大家应该都知道在默认情况下,使用vim打开文本文件都是灰蒙蒙的一片,当我们要在其中查询某个字符的时候也看的不清楚。但是,其实是有办法解决这种困境。下面这篇文章就给给大家分享了在Mac OS X中设置VIM语法高亮的方法,有需要的朋友们可以参考借鉴,下面来一起看看。
    2016-11-11
  • 详解Linux中nginx如何重启、启动与停止

    详解Linux中nginx如何重启、启动与停止

    这篇文章主要给大家详细介绍了Linux中nginx如何重启、启动与停止/设置开机自启动,小编觉得挺不错的,现在分享给大家,也给大家做个参考,一起跟随小编过来看看吧<BR>
    2023-12-12
  • Linux检查Swap交换空间的五个命令小结

    Linux检查Swap交换空间的五个命令小结

    这篇文章主要给大家介绍了关于Linux中检查Swap交换空间的五个命令的相关资料,文中通过示例代码介绍的非常详细,对大家学习或者使用linux具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2018-10-10
  • linux下安装php扩展memcache的方法

    linux下安装php扩展memcache的方法

    这篇文章主要介绍了linux下安装php扩展memcache的方法,需要了解的朋友可以参考下
    2015-07-07
  • Linux查看命令之od命令详解

    Linux查看命令之od命令详解

    Linux查看命令之od命令的作用主要是以指定格式查看文件内容。下面的本文先给大家简单介绍了od命令的参数,然后通过示例详细给加演示了od命令的使用,有需要的朋友们可以参考借鉴,下面来一起看看吧。
    2016-12-12
  • linux下查看已经安装的jdk 并卸载jdk的方法(推荐)

    linux下查看已经安装的jdk 并卸载jdk的方法(推荐)

    下面小编就为大家带来一篇linux下查看已经安装的jdk 并卸载jdk的方法(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2016-11-11
  • Linux域名服务DNS配置方法

    Linux域名服务DNS配置方法

    DNS 全称是 Domain Name System,大意是域名解析系统,它的职责是把域名翻译成一个一个可以识别的 IP 供不同的计算机设备连接。这篇文章主要介绍了Linux域名服务DNS配置方法,需要的朋友可以参考下
    2019-08-08
  • 实战基本的Linux sed命令示例代码

    实战基本的Linux sed命令示例代码

    Linux流编辑器是在数据中心中运行脚本的一种有用方法。通过这些命令示例,您可以开始熟悉sed,需要的朋友可以参考下
    2018-10-10
  • 详解linux下查看系统版本号信息的方法(总结)

    详解linux下查看系统版本号信息的方法(总结)

    本篇文章主要介绍了详解CentOS下查看系统版本号信息的方法(总结),具有一定的参考价值,有兴趣的可以来了解一下
    2017-07-07
  • Ubuntu 14.04设置开机启动脚本的方法

    Ubuntu 14.04设置开机启动脚本的方法

    这篇文章主要给大家介绍了Ubuntu 14.04设置开机启动脚本的方法,文中通过代码介绍的很详细,相信对大家的理解和学习具有一定的参考借鉴价值,有需要的朋友们下面来跟着小编一起学习学习吧。
    2016-12-12

最新评论