CentOS下手动Step By Step安装GitLab

GitLab一键安装脚本主要是采用了脚本gitlab-install-el6.sh来实现的,里面包含了很多的配置步骤,如果本地不是一个全新的环境,那么最好按照以下步骤来进行手动配置:

1>尽量多地增加安装源查看yum源:yum repolist
a) 增加EPEL安装源#rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
b) 增加PUIAS安装源
c) 增加RHEL6安装源

2>安装常用库文件
# yum install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib glibc glibc-devel glib2 glib2-devel gd gd-devel bzip2 bzip2-devel ncurses ncurses-devel curl openssl libtool libtool-devel libtool-ltdl-devel httpd

3>安装git需要库文件
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

4>安装git(git --version显示版本,则说明安装成功)
# yum install git

5>安装git所需依赖包
# yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui  python-devel redis sudo wget crontabs logwatch logrotate perl-Time-HiRes

6>安装Ruby

7>安装Redis并启动

8>安装MySql并启动(启动后以root账户登录并执行下列语句(如果不能以root账号登录,参见http://blog.csdn.net/yanjiangbo/article/details/39076823
> CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
> UPDATE mysql.user SET Password=PASSWORD('gitlab') WHERE User='root'; FLUSH PRIVILEGES;
> create database gitlab;
> grant all privileges on gitlab.* to "gituser"@"localhost"identified by "gitpwd";
> exit;

9>安装bundle
# yum install bundler --no-ri --no-rdoc
安装成功后显示:
Fetching: bundler-1.7.2.gem (100%)
Successfully installed bundler-1.7.2
1 gem installed

10>创建git用户
# adduser --system --create-home --comment 'GitLab' git
# chmod 755 /home/git/
# su - git

11>配置gitlab-shell
# su - git
$ git clone https://github.com/gitlabhq/gitlab-shell.git
$ cd gitlab-shell
$ git checkout v1.8.0
$ cp config.yml.example config.yml
$ vim config.yml 修改域名为:gitlab_url: "http://git.os.com/"
$ ./bin/install

12>安装并配置GitLab
# su - git
$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
$ cd /home/git/gitlab
$ git checkout 6-3-stable
$ cp config/gitlab.yml.example config/gitlab.yml
$ vim config/gitlab.yml

加入域名
## GitLab settings
gitlab:
## Web server settings
  host: git.os.com
  port: 80
  https: false

$ cp config/database.yml.mysql config/database.yml
$ vim config/database.yml(修改数据库用户密码)

$ chmod o-rwx config/database.yml
$chown -R git log/
$chown -R git tmp/
$chmod -R u+rwX log/
$chmod -R u+rwX tmp/
$mkdir tmp/pids/
$mkdir tmp/sockets/
$chmod -R u+rwX tmp/pids/
$chmod -R u+rwX tmp/sockets/
$mkdir public/uploads
$chmod -R u+rwX public/uploads
$cp config/unicorn.rb.example config/unicorn.rb
$cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
$git config --global user.name "GitLab"
$git config --global user.email "gitlab@localhost"
$git config --global core.autocrlf input


13>安装Gems(一定务必更改Gemfile配置文件,配置中国可用的镜像http://ruby.taobao.org/
# gem install charlock_holmes --version '0.6.9.4'
# su - git
$ cd /home/git/gitlab$
bundle install --full-index --deployment --without development test postgres puma aws(非常耗时的一步,还经常出错)如果不加--full-index可能会出错:详见: https://github.com/bundler/bundler/issues/2618 https://github.com/bundler/bundler/issues/2769

14>对数据库进行初始化
先启动redis
# /etc/init.d/redis restart
$ bundle exec rake gitlab:setup RAILS_ENV=production --verbose
记住这个,是登录的帐号密码
login.........root
password......5iveL!fe

15>启动GitLab

# wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn -P /etc/init.d/
# mv /etc/init.d/gitlab-unicorn /etc/init.d/gitlab
# chmod +x /etc/init.d/gitlab# su - git $ cd /home/git/gitlab$ cp -r script/ bin $ exit
# /etc/init.d/gitlab restart(启动gitlab)

16>配置Gi检测应用程序状态
$ bundle exec rake gitlab:env:info RAILS_ENV=production
详细信息
$ bundle exec rake gitlab:check RAILS_ENV=production

17>安装配置nginx并启动# cp /home/git/gitlab/lib/support/nginx/gitlab /usr/local/nginx/conf/conf.d/gitlab.conf
# chown git.git /usr/local/nginx/conf/conf.d/gitlab.conf
# vim gitlab.conf

修改日志路径,域名
vim /usr/local/nginx/conf/ngxin.conf
加入

includ conf.d/gitlab.conf;


/usr/local/nginx/sbin/nginx



【启动】
# /etc/init.d/redis restart
# /etc/init.d/gitlab restart
# /usr/local/nginx/sbin/nginx


==================================================================================================


#PS:遇到如下报错
$ bundle exec rake gitlab:check RAILS_ENV=production
Check GitLab API access: /usr/local/lib/ruby/2.1.0/net/http.rb:879:in `initialize': getaddrinfo: No address associated with hostname (SocketError)
    from /usr/local/lib/ruby/2.1.0/net/http.rb:879:in `open'
    from /usr/local/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'
    from /usr/local/lib/ruby/2.1.0/timeout.rb:76:in `timeout'
    from /usr/local/lib/ruby/2.1.0/net/http.rb:878:in `connect'
    from /usr/local/lib/ruby/2.1.0/net/http.rb:863:in `do_start'
    from /usr/local/lib/ruby/2.1.0/net/http.rb:852:in `start'
    from /home/git/gitlab-shell/lib/gitlab_net.rb:62:in `get'
    from /home/git/gitlab-shell/lib/gitlab_net.rb:29:in `check'
    from /home/git/gitlab-shell/bin/check:11:in `<main>'
gitlab-shell self-check failed
  Try fixing it:
  Make sure GitLab is running;
  Check the gitlab-shell configuration file:
  sudo -u git -H editor /home/git/gitlab-shell/config.yml
  Please fix the error above and rerun the checks.


编辑如下三个文件,域名端口要对应
$vim config/gitlab.yml
  gitlab:
    ## Web server settings
    host: git.os.com
    port: 8099
    https: false
$vim ../gitlab-shell/config.yml
gitlab_url: "http://git.os.com:8099"
$ vim config/unicorn.rb
listen "127.0.0.1:8099", :tcp_nopush => true
另外,hosts最好也加上要解析的域名
$ vim /etc/hosts

127.0.0.1       git.os.com    git

#出现错误:Couldnot find modernizr-2.6.2 in any of the sources

#解决办法:

1.

#wget http://rubygems.org/downloads/modernizr-2.6.2.gem

#gem install modernizr


2.

$gem sources --remove https://rubygems.org/

$gem source -a http://ruby.taobao.org/

$gem sources -l


3.

将Gemfile和Gemfile.lock配置文件的modernizr版本更改成2.7.1:

$vim Gemfile

gem "modernizr"    "2.6.2"   ===> gem "modernizr-rails",        "2.7.1"


$vim Gemfile.lock

modernizr  (2.6.2)   ===>     modernizr-rails (2.7.1)

modernizr  (2.6.2)   ===>     modernizr-rails (= 2.7.1)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值