RHEL(redhat 5.x,6.x)和CentOS上Gitlab安装全过程
来源:互联网 发布:mac版lol国服何时出 编辑:程序博客网 时间:2024/05/29 21:16
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以上
首先执行:
su -yum -y updateyum -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源
sudo wget-O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txtsudo rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
验证一下key是否成功安装:
sudo rpm-qa gpg*gpg-pubkey-0608b895-4bd22942
现在安装epel-release-6-8.noarch包,用来给系统启用EPEL源:
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:
[PUIAS_6_computational]name=PUIAScomputational Base $releasever - $basearchmirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist#baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearchgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias
(2)Next download and install the gpg key.
sudo wget-O /etc/pki/rpm-gpg/RPM-GPG-KEY-puiashttp://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puiassudo rpm--import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias
(3)Verify that the key got installedsuccessfully:
sudo rpm-qa gpg*gpg-pubkey-41a40948-4ce19266
(4)Verify that the EPEL and PUIASComputational repositories are enabled as shown below:
sudo yumrepolistrepoid repo name statusPUIAS_6_computational PUIAS computational Base 6 - x86_64 2,018base CentOS-6 - Base 4,802epel Extra Packages forEnterprise Linux 6 - x86_64 7,879extras CentOS-6 - Extras 12updates CentOS-6 - Updates 814repolist:15,525
(5)If you can't see them listed, use thefolowing command (from yum-utils package) to enable them:
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:
sudochkconfig redis onsudoservice redis start
3.2 配置sendmail
如果你是用smtp方式发送邮件,可直接跳过。
参考https://github.com/lubia/gitlab-recipes/tree/master/install/centos#configure-sendmail
3.3 安装ruby
下载并编译:
su -mkdir/tmp/ruby && cd /tmp/rubycurl--progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz | tar xzcdruby-2.1.0./configuremake&& make install
验证:
ruby -v# ruby2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
安装the Bundler Gem:
sudo gem install bundler --no-ri --no-rdocsudo geminstall charlock_holmes -v '0.6.9.4'
改为应用淘宝的源:
sudo gem sources --remove https://rubygems.org/sudo gem sources -a http://ruby.taobao.org/sudo gem install bundler
添加以下软连接,否则可能提示找不到:
ln -s /usr/local/bin/ruby /usr/bin/rubyln -s /usr/local/bin/gem /usr/bin/gemln -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位,所以选择如上。
下载完毕,
rpm –ivh *.rpm --force –nodeps。
启动起来并设置成开机启动。
四、开始正式安装
4.1 账户配置
4.1.1创建Git用户
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:
su -echoadminlogs@example.com > /root/.forwardchown root/root/.forwardchmod 600/root/.forwardrestorecon/root/.forward echoadminlogs@example.com > /home/git/.forwardchown git/home/git/.forwardchmod 600/home/git/.forwardrestorecon/home/git/.forward
4.2 安装GitLab shell
GitLab Shell is a ssh access and repository managementsoftware developed specially for GitLab.
# Firstlogin as rootsu - # Login asgitsu - git # Clonegitlab shellgit clonehttps://github.com/gitlabhq/gitlab-shell.gitcdgitlab-shell # Switchto right versiongitcheckout v1.8.0cpconfig.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:
# Login toMySQLmysql -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 databaseCREATEDATABASE 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\qTry 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
确认是否安装成功完成:
su - gitcd 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
su -yum -yinstall nginxchkconfignginx onmkdir/etc/nginx/sites-{available,enabled}wget -O/etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx/gitlab-sslln -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.
usermod -a-G git nginxchmod g+rx/home/git/
Note: Don't forget to add a SSL certificate or generate aSelf Signed Certificate
cd/etc/nginxopensslreq -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key
vi/etc/nginx/site-available/gitlab
让nginx监听80端口,root目录是gitlab的网站,这样可以通过机器ip:80来访问。
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
- RHEL(redhat 5.x,6.x)和CentOS上Gitlab安装全过程
- centos 6.x安装gitlab
- 在Centos 5.x或6.x上安装RHEL EPEL Repo
- 在Centos 5.x或6.x上安装RHEL EPEL Repo
- 在Centos 5.x或6.x上安装RHEL EPEL Repo
- CentOS/RHEL安装X Window
- CentOS 6.x安装配置GitLab(企业版Git管理)
- rhel 5.x和rhel 6.x网卡绑定
- Centos 5.x RHEL 5.x 安装salt升级Zmq2.x 到Zmq4.x
- 如何在CentOS 6.X 或 redhat 上安装JDK runtime environment (openjdk)
- Nagios 4.0.1版本安装 适用于RHEL/Centos 5.x/6.x 或者Fedora 17/18/19(一)
- How to Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x
- Oracle Database 11g Release 2 Installation on RHEL/CentOS 6.x/5.x/4.x
- How to Enable EPEL Repository for RHEL/CentOS 7.x/6.x/5.x
- RHEL/CentOS 7.x/6.x/5.x开启EPEL仓库
- CentOS 6.x安装配置GitLab(社区或个人Git管理)
- RHEL/CentOS 6.x 系统服务详解
- RHEL/CentOS 6.x 系统服务详解
- C++内存对象大会战2
- RadioGroup 的 RadioButton 选择改变字体颜色和背景颜色
- 人生就是一阵风,起了,没了。理想就是一盏灯,燃了,灭了
- 使用 google-perftools 剖析程序性能瓶颈
- 微信开发者功能
- RHEL(redhat 5.x,6.x)和CentOS上Gitlab安装全过程
- 开方数 时间限制:500 ms | 内存限制:65535 KB 难度:3
- 海康威视笔试试题(DSP/嵌入式)
- js中获得当前时间是年份和月份
- [LeetCode]Swap Nodes in Pairs
- touch
- 浅谈BST (Binary Search Tree)
- 微信公众平台群发规则说明
- linux驱动工程面试必问知识点