`

linux gitlab nginx 安装 配置 详解

    博客分类:
  • git
 
阅读更多
原文地址:http://blog.51yip.com/server/1558.html


linux gitlab nginx 安装 配置 详解
张映 发表于 2013-09-28
分类目录: 服务器相关
花了一天的时间装了一下gitlab,本以为2-3个小时就能搞定的东西,没想到花了一天,被github官网的一键安装包给坑了,gitlab-install-el6.sh,网上很多人说可以用,但是我用不了,我的系统是centos 6.4 x86_64,基本上全新的系统,装了php,nginx,mysql,下面说一下安装的详细过程
一,什么是gitlab
GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。
它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。
个人觉得,gitlab是将来代码版本控制的趋势,就像当年的SVN代替CVS是一样的。多项目的版本控制,代码的review等,优势很明显,特别是项目很多的公司,gitlab能够减轻技术经理的负担,并有效监控代码质量,对技术人员工作状态都能有所了解(可以通过查看commit记录)
二,安装epel源
请参考:centos 推荐使用epel源
三,安装git
yum install git 
有的人说一键安装是可以用的,我也相信了,但是不行。有兴趣的朋友,可以下一下试试,其实我的安装,也是在一键安装的基本上改的。以下是一键安装,建议大家不要用,因为根本用不了。
查看复制打印?
git clone https://github.com/mattias-ohlsson/gitlab-installer.git 
cd gitlab-installer/     //该目录有一键安装的sh脚本 
./gitlab-install-el6.sh 
四,安装系统依赖
yum  install patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel 
五,安装rvm
查看复制打印?
curl -L get.rvm.io | sudo bash -s stable 
source /etc/profile.d/rvm.sh 
rvm pkg install libyaml 
rvm install 1.9.3 
rvm --default use 1.9.3 
gem install bundler 
在这里一键安装包有一个严重的问题,
[root@localhost zhangy]# command rvm install 1.9.3-p392 --with-libyaml-dir=/usr/local/rvm/usr
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-1.9.3-p392, this may take a while depending on your cpu(s)...
ruby-1.9.3-p392 - #downloading ruby-1.9.3-p392, this may take a while depending on your connection...
Archive ruby-1.9.3-p392.tar.bz2 checksum did not match, downloading again.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
84 9789k   84 8308k    0     0  14093      0  0:11:51  0:10:03  0:01:48 12600
curl: (18) transfer closed with 1516640 bytes remaining to read
Partial file(18). Only a part of the file was transferred. Removing partial and re-trying.
总是会提示错误,并且会不断的去Removing partial and re-trying.会不断的重复下载,并且没有一次能下载完成,卡死在这儿了。
正确做法是:
查看复制打印?
[root@localhost zhangy]# rvm install 1.9.3 
Searching for binary rubies, this might take some time. 
Checking requirements for centos. 
Requirements installation successful. 
ruby-1.9.3-p448 - #configure 
ruby-1.9.3-p448 - #download 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100  9.9M  100  9.9M    0     0  12049      0  0:14:30  0:14:30 --:--:-- 14521 
ruby-1.9.3-p448 - #validate archive 
ruby-1.9.3-p448 - #extract 
ruby-1.9.3-p448 - #validate binary 
ruby-1.9.3-p448 - #setup 
Saving wrappers to '/usr/local/rvm/wrappers/ruby-1.9.3-p448'........ 
。。。。。。。。。。。。。以下省略。。。。。。。。。。。。。。 
六,创建git用户
查看复制打印?
adduser --system --create-home --comment 'GitLab' git 
七,配置gitlab-shell
查看复制打印?
su - git -c "git clone https://github.com/gitlabhq/gitlab-shell.git" 
su - git -c "cd gitlab-shell && git checkout v1.3.0" 
su - git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml" 
sed -i "s/localhost/gitlab.51yip.com/g" /home/git/gitlab-shell/config.yml 
su - git -c "gitlab-shell/bin/install" 
chmod 600 /home/git/.ssh/authorized_keys 
chmod 700 /home/git/.ssh 
八,安装redis
yum -y install redis 
service redis start 
chkconfig redis on 
九,安装配置mysql
查看复制打印?
yum install mysql-server 
chkconfig mysqld on 
 
echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root 
 
echo "UPDATE mysql.user SET Password=PASSWORD('123456') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root 
如果以前设置过mysql的root密码,上面的最后一步的修改 root密码这一步可以不用做。| mysql -u root -p来创建gitlab的数据库了
十,安装配置gitlab
查看复制打印?
su - git -c "git clone https://github.com/gitlabhq/gitlabhq.git gitlab" 
su - git -c "cd gitlab;git checkout 5-1-stable" 
su git -c "cp config/gitlab.yml.example config/gitlab.yml" 
su git -c "mkdir /home/git/gitlab-satellites" 
su git -c "mkdir public/uploads" 
su git -c "mkdir -p tmp/sockets/" 
su git -c "mkdir -p tmp/pids/" 
sed -i "s/ host: localhost/ host: gitlab.51yip.com/g" config/gitlab.yml 
sed -i "s/from: gitlab@localhost/from: gitlab@gitlab.51yip.com/g" config/gitlab.yml 
su git -c "cp config/puma.rb.example config/puma.rb" 
su git -c 'git config --global user.name "GitLab"' 
su git -c 'git config --global user.email "gitlab@gitlab.51yip.com"' 
十一,配置mysql数据库连接
查看复制打印?
su git -c "cp config/database.yml.mysql config/database.yml" 
sed -i "s/secure password/mysql的root密码/g" config/database.yml 
十二,安装gems
查看复制打印?
yum  install libicu-devel 
cd /home/git/gitlab 
gem install charlock_holmes --version '0.6.9' 
 
yum  install mysql-devel 
su git -c "bundle install --deployment --without development test postgres" 
su git -c "bundle exec rake sidekiq:start RAILS_ENV=production" 
 
export force=yes 
su git -c "bundle exec rake gitlab:setup RAILS_ENV=production" 
 
curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab 
chmod +x /etc/init.d/gitlab 
 
sed -i "17 a source /etc/profile.d/rvm.sh\nrvm use 1.9.3-p448" /etc/init.d/gitlab 
 
chkconfig gitlab on 
service gitlab start 
注意:
1,gem install charlock_holmes --version '0.6.9'
查看复制打印?
Enclosing class/module 'rb_mCharlockHolmes' for class EncodingDetector not known 
unable to convert "\x80" from ASCII-8BIT to UTF-8 for ext/charlock_holmes/dst/bin/file, skipping 
unable to convert "\xEE" from ASCII-8BIT to UTF-8 for ext/charlock_holmes/src/file-5.08/magic/Magdir/wordprocessors, skipping 
unable to convert "\xE1" from ASCII-8BIT to UTF-8 for ext/charlock_holmes/src/file-5.08/magic/Magdir/natinst, skipping 
如果出现上面的问题,不用理会,不影响使用。
2,su git -c "bundle install --deployment --without development test postgres"
这一步时,如果出现会卡死的情况,卡在Installing foreman (0.61.0) 这儿,请耐心等待
3,gitlab:check时报GitLab Shell version? ... FAIL. Please update gitlab-shell to v1.1.0,不用理会,不影响使用
4,gitlab settings 500错误。一定要加上,su git -c "bundle exec rake sidekiq:start RAILS_ENV=production"
十三,安装配置nginx
查看复制打印?
yum install nginx 
curl --output /etc/nginx/conf.d/gitlab.conf https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/nginx/gitlab 
 
vim /etc/nginx/conf.d/gitlab.conf 
listen gitlab.51yip.com; 
server_name gitlab.51yip.com; 
十四,设置gitlab-shell
查看复制打印?
vim /home/git/gitlab-shell/bin/gitlab-shell 
#!/usr/local/rvm/bin/ruby-1.9.3-p448   //将脚本的Ruby版本指向到ruby-1.9.3-p448安装版本 
十五,重启gitlab和nginx
查看复制打印?
/etc/init.d/nginx restart 
/etc/init.d/gitlab restart 
 
[root@gitlab conf.d]# /home/git/gitlab-shell/bin/check       //不报错就OK了 
Check GitLab API access: OK 
Check directories and files: 
    /home/git/repositories: OK 
    /home/git/.ssh/authorized_keys: OK 
有一点要注意,就是gitlab5-0-stable和gitlab5-1-stable有一点不同的是,启动成功后,gitlab5-0-stable是有启动进程的如下图,而gitlab5-1-stable,是没有的。推荐大家使用5-1-stable。
gitlab start
gitlab start
到这儿,gitlab就安装完成了,其实挺麻烦的,要耐下心来,一步一步来完成就行了,来看一下效果图:
gitlab 完成
gitlab 完成
>用户名:admin@local.host
密  码:5iveL!fe
0

转载请注明
作者:海底苍鹰
地址:http://blog.51yip.com/server/1558.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics