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

[经验分享] RHEL(redhat 5.x,6.x)和CentOS上Gitlab安装全过程

[复制链接]

尚未签到

发表于 2016-5-13 09:18:34 | 显示全部楼层 |阅读模式
原文地址:http://blog.csdn.net/ypjyangpeijun/article/details/20468043

RHEL(redhat 5.x,6.x)和CentOS上Gitlab安装全过程
2014-03-06 17:55 538人阅读 评论(0) 收藏 举报
gitlabRHELCentOSsmtpredhat
目录(?)[+]
RHEL和CentOS 上Gitlab安装全过程
这两天一直在折腾gitlab的安装,由于官方建议ubuntu系统上安装,所以在RHEL颇经周折。从一开始在RHEL 5.8上安装,后来又换了服务器,又在RHEL 6.5上安装。不过经过倒腾,大概明白了Gitlab在RHEL和CentOS上的安装思路,虽然实际安装使用的是RHEL6.5版本,但相信本文档针对其他版本的RHEL和CentOS安装Gitlab也是很具有参考意义的。
本文主要参考:
(1)  官方文档:https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/install,基于Ubuntu
          installation.md安装步骤
          requirements.md系统环境要求
(2)  https://github.com/lubia/gitlab-recipes/tree/master/install/centos
本文结合以上两个参考资料,尤其是(2),进行了翻译整理,并把自己再实际安装过程中遇到的问题记录了下来。

一、预安装

ruby     1.9.3+
git     1.7.10+
redis     2.0+
MySQL     or PostgreSQL
python     2.5以上
首先执行:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su -  
yum -y update  
yum -y groupinstall 'Development Tools'  
yum -y install vim-enhanced readline readline-devel ncurses-develgdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-develbyacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2libxml2-devel libxslt libxslt-devel libicu libicu-develsystem-config-firewall-tui python-devel redis sudo wget crontabs logwatchlogrotate perl-Time-HiRes  

我理解的整个安装过程就是确保上面的软件能全部安装,并确保ruby、git、redis、python的版本。

执行完了么?

Python太低了?
系统的python可不能卸载,依赖它的包太多了,千万不能用yum –y remove来卸载,系统会崩的。一个系统可以安装多个版本的python,可以参考文章
http://blog.haohtml.com/archives/13959来安装新版本的python。

Git版本太低了?
这个可以yum remove git来卸载系统的git。登陆https://github.com/git/git/releases ,选择新一点稳定的git(1.8.x以上)版本,源码安装即可。
./configure不需要指定安装路径,默认安装就行。

yum提示找不到package?
      好吧,莫慌,是redhat/centos 6.x系列么?
             如果是。参考“二、系统添加EPEL、PUIAS、Rpmforge源”,给yum添加这三个源以后,再执行一开始的yum install一大串试试。、
             如果还是提醒找不到某些package?参考下面的地址,看看能不能找到安装包。
      
      这里有一个网址,http://rpmfind.net/linux/rpm2html/search.php?query=&submit=Search+...&system=&arch=,可以搜到很多系统的rpm安装包,下载到一个目录,执行rpm –ivh *.rpm --force –nodeps。
      但是有一点,要求搜索的软件包一定要适合系统的类型、版本,要不然会造成系统不稳定。
      
      如果经过上述一些步骤,yum install一大串试试,还是提示一些包找不到,那就得自己动手去其他地方试试了。但是RHEL、CentOS 6.5系列绝对没有问题。

至此,准备工作做完了,可继续3。如果做不完,要不考虑换换系统?

二、系统添加EPEL、PUIAS源(RHEL、CentOS 6.x)
2.1 添加EPEL源
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo wget-O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt  
sudo rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6  
验证一下key是否成功安装:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo rpm-qa gpg*  
gpg-pubkey-0608b895-4bd22942  
现在安装epel-release-6-8.noarch包,用来给系统启用EPEL源:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo rpm-Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm  

Note: Don'tmind the x86_64, if you install on a i686 system you can use the samecommands.

2.2 添加PUIASComputational源
(1)Create/etc/yum.repos.d/PUIAS_6_computational.repo and add the following lines:

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
[PUIAS_6_computational]  
name=PUIAScomputational Base $releasever - $basearch  
mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist  
#baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch  
gpgcheck=1  
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias  


(2)Next download and install the gpg key.
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo wget-O /etc/pki/rpm-gpg/RPM-GPG-KEY-puiashttp://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias  
sudo rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias  

(3)Verify that the key got installedsuccessfully:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo rpm-qa gpg*  
gpg-pubkey-41a40948-4ce19266  

(4)Verify that the EPEL and PUIASComputational repositories are enabled as shown below:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo yumrepolist  
repoid                 repo name                                               status  
PUIAS_6_computational   PUIAS computational Base 6 - x86_64                      2,018  
base                    CentOS-6 - Base                                          4,802  
epel                    Extra Packages forEnterprise Linux 6 - x86_64          7,879  
extras                  CentOS-6 - Extras                                           12  
updates                 CentOS-6 - Updates                                         814  
repolist:15,525  
(5)If you can't see them listed, use thefolowing command (from yum-utils package) to enable them:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudoyum-config-manager --enable epel --enable PUIAS_6_computational  

三、Ruby、mysql、redis等软件安装
    Gitlab、redis、nginx等将来都配置成开机启动,且会是用sendmail发送邮件。
3.1 配置redis开机启动
Make sure redis is started on boot:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudochkconfig redis on  
sudoservice redis start  
3.2 配置sendmail
如果你是用smtp方式发送邮件,可直接跳过。
参考https://github.com/lubia/gitlab-recipes/tree/master/install/centos#configure-sendmail
3.3 安装ruby
下载并编译:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su -  
mkdir/tmp/ruby && cd /tmp/ruby  
curl--progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz | tar xz  
cdruby-2.1.0  
./configuremake&& make install  
验证:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
ruby -v  
# ruby2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]  
安装the Bundler Gem:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo gem install bundler --no-ri --no-rdoc  
udo geminstall charlock_holmes -v '0.6.9.4'  
改为应用淘宝的源:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
sudo gem sources --remove https://rubygems.org/  
sudo gem sources -a http://ruby.taobao.org/  
sudo gem install bundler  
添加以下软连接,否则可能提示找不到:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
ln -s /usr/local/bin/ruby /usr/bin/ruby  
ln -s /usr/local/bin/gem /usr/bin/gem  
ln -s /usr/local/bin/bundle /usr/bin/bundle  

3.4 安装mysql

从http://mirrors.sohu.com/mysql/MySQL-5.0/选好mysql版本,下载

MySQL-client-5.5.36-1.el6.x86_64.rpm
MySQL-devel-5.5.36-1.el6.x86_64.rpm
MySQL-server-5.5.36-1.el6.x86_64.rpm
MySQL-shared-5.5.36-1.el6.x86_64.rpm  
MySQL-shared-compat-5.5.36-1.el6.x86_64.rpm
不同的机器选用不同的下载包,本人是redhat 6.5,64位,所以选择如上。
下载完毕,
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
rpm –ivh *.rpm --force –nodeps。  
启动起来并设置成开机启动。

四、开始正式安装
4.1 账户配置

      4.1.1创建Git用户
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su -  
adduser--system --shell /bin/bash --comment 'GitLab' --create-home --home-dir/home/git/ git  
设置为git用户不能登录.

      4.1.2转发所有邮件:(如用smtp方式,可跳过)

Now we want all logging of the system to be forwarded toa central email address:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su -  
echoadminlogs@example.com > /root/.forward  
chown root/root/.forward  
chmod 600/root/.forward  
restorecon/root/.forward  
   
echoadminlogs@example.com > /home/git/.forward  
chown git/home/git/.forward  
chmod 600/home/git/.forward  
restorecon/home/git/.forward  

4.2 安装GitLab shell

GitLab Shell is a ssh access and repository managementsoftware developed specially for GitLab.
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
# Firstlogin as root  
su -  
   
# Login asgit  
su - git  
   
# Clonegitlab shell  
git clonehttps://github.com/gitlabhq/gitlab-shell.git  
cdgitlab-shell  
   
# Switchto right version  
gitcheckout v1.8.0  
cpconfig.yml.example config.yml  
   
# Editconfig and replace gitlab_url with something like 'http://domain.com/'  
#  
# Note,'gitlab_url' is used by gitlab-shell to access GitLab API. Since   
#     1. the whole communication is locally  
#     2. next steps will explain how to exposeGitLab over HTTPS with custom cert  
# it's agood solution is to set gitlab_url as "http://localhost:8080/"  
   
# Do setup  
./bin/install  

4.3 选择数据库

    4.3.1 MySQL(建议)
Create a new user and database for GitLab:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
# Login toMySQL  
mysql -uroot -p  
# Type thedatabase root password  
# Create auser for GitLab. (change supersecret to a real password)  
CREATEUSER 'gitlab'@'localhost' IDENTIFIED BY 'supersecret';  
   
# Createthe GitLab production database  
CREATEDATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8`COLLATE `utf8_unicode_ci`;  
   
# Grantthe GitLab user necessary permissopns on the table.  
GRANTSELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON`gitlabhq_production`.* TO 'gitlab'@'localhost';  
   
# Quit thedatabase session  
\q  
Try connecting to the new database with the new user:  
mysql -ugitlab -p -D gitlabhq_production  
# Type thepassword you replaced supersecret with earlier  
# Quit thedatabase session  
\q  

    4.3.2 PostgreSQL
    参考https://github.com/lubia/gitlab-recipes/tree/master/install/centos#52-postgresql


4.4 安装GitLab

参考https://github.com/lubia/gitlab-recipes/tree/master/install/centos#6-gitlab
确认是否安装成功完成:
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su - git  
cd gitlab/  
bundleexec rake gitlab:check RAILS_ENV=production  



      Do not care about it if you are sure that you have downloaded the up-to-date filefrom https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn andsaved it to /etc/init.d/gitlab.
If all other items are green, then congratulations on successfully installingGitLab! However there are still a few steps left.

4.4.1 Unicorn.rb, gitlab.yml, config.yml配置文件
    gitlab的配置依赖于三个文件
/home/git/gitlab/config/unicorn.rb:配置ruby提供的服务端口,ip
   
/home/git/gitlab/config/gitlab.yml:配置gitlab服务的端口,ip
   
/home/git/gitlab-shell/config.yml:配置gitlab-shell要调用的API接口
        
    修改host转发,Vi/etc/hosts
   
4.5 配置SMTP发送邮件

    可选。如果选用sendmail方式,可跳过此步。
   
    修改gitb.yml, vi gitlab/config/gitlab.yml

    确保上面三处填写邮件的地方邮箱一致,Service gitlab restart即可。

4.6 安装配置nginx

[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
su -  
yum -yinstall nginx  
chkconfignginx on  
mkdir/etc/nginx/sites-{available,enabled}  
wget -O/etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx/gitlab-ssl  
ln -sf/etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab  
Edit /etc/nginx/nginx.conf and replace include /etc/nginx/conf.d/*.conf; with include /etc/nginx/sites-enabled/*;
Edit /etc/nginx/sites-available/gitlab and replace git.example.com with your FQDN.
Add nginx user to git group.
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
usermod -a-G git nginx  
chmod g+rx/home/git/  

Note: Don't forget to add a SSL certificate or generate aSelf Signed Certificate
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
cd/etc/nginx  
opensslreq -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key  

vi/etc/nginx/site-available/gitlab


让nginx监听80端口,root目录是gitlab的网站,这样可以通过机器ip:80来访问。
[plain] view plaincopyprint?在CODE上查看代码片派生到我的代码片
service nginx restart  

五、安装完毕

假设你的电脑的IP是192.168.1.2,如果你的my.ubuntu.com域名指向192.168.1.2的话可以直接用
Http://192.168.1.2后台http://my.ubuntu.com,用以下账号登陆。
admin@local.host
5iveL!fe

运维网声明 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-216328-1-1.html 上篇帖子: [转]centOS 6.3 安装 最新版git 下篇帖子: redhat/centos 6.3 搭建git/gitosis/gitweb详细过程(1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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