设为首页 收藏本站
查看: 705|回复: 0

[经验分享] linux gitlab nginx 安装 配置 详解

[复制链接]

尚未签到

发表于 2016-2-27 10:23:07 | 显示全部楼层 |阅读模式
原文地址: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  
在这里一键安装包有一个严重的问题,
[iyunv@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.会不断的重复下载,并且没有一次能下载完成,卡死在这儿了。
正确做法是:
查看复制打印?
[iyunv@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  
  
[iyunv@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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-183400-1-1.html 上篇帖子: Linux 下一步步安装 Git Server 下篇帖子: 转:linux教程:Git使用技巧篇
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表