简单安装
Omnibus 包安装 GitLab
http://www.21yunwei.com/archives/4351
http://peiqiang.net/2014/07/30/install-gitlab.html
http://blog.csdn.net/hustpzb/article/details/8230454/
源码安装
一、环境
gitlab的安装说明https://github.com/lubia/gitlab-recipes/tree/master/install/centos
系统:CentOS6.4最小化安装
gitlab 5.2.0
centos64
Redis 2.6.13
nginx-1.4.1
mysql-
gitlab中文使用指南:GitLab使用介绍
首先我们选择比较快的yum源,不然安装速度会非常的慢的.这里使用中国科技大学的yum源http://lug.ustc.edu.cn/wiki/mirrors/help/centos更换yum源方法参考:http://blog.haohtml.com/archives/5669,
三。默认安装的git版本可能会低一些,需要升级到最新版本才可以.
yum -y
install
readline-devel gdbm-devel ncurses-devel openssl-devel zlib-devel
gcc
gcc
-c++
make
autoconf curl-devel expat-devel gettext-devel tk-devel libxml2-devel libffi-devel libxslt-devel libicu-devel git-all python-devel vim
sudo
四、安装git
删除系统默认的git,使用源码安装git
[root@gitlab~]
#git--version
gitversion1.7.1
[root@gitlab~]
#yumremovegit-y
#下载源码安装包
[root@gitlab~]
#wgethttps://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz
[root@gitlab~]
#tar zxfgit-2.1.3.tar.gz
[root@gitlab~]
#cdgit-2.1.3
[root@gitlabgit-2.1.3]
#./configure
[root@gitlabgit-2.1.3]
#make&&makeprefix=/usr/localinstall
[root@gitlabgit-2.1.3]
#ln-s/usr/local/bin/git/usr/bin/
[root@gitlabgit-2.1.3]
#git--version
gitversion2.1.3
删除系统自带的ruby环境,确保ruby是2.0以上的版本
[root@gitlab~]
#yumremoveruby-y
#下载ruby安装包,最少2.0以上
[root@gitlab~]
#wgetftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.2.tar.gz
[root@gitlab~]
#tar zxvfruby-2.1.2.tar.gz
[root@gitlab~]
#cdruby-2.1.2
[root@gitlabruby-2.1.2]
#./configure--prefix=/usr/local/
[root@gitlabruby-2.1.2]
#make&&makeinstall
安装bundler
[root@gitlabruby-2.1.2]
#geminstallbundler--no-doc
六、创建git用户
[root@gitlab~]
#adduser--system--shell/bin/bash--comment'GitLab'--create-home--home-dir/home/git/git
查看MysqL安装结果
创建数据库并授权
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
[root@gitlab~]
#MysqL-uroot-p-h127.0.0.1
Enterpassword:
#这里的密码是我的安装脚本中提供的密码
WelcometotheMysqLmonitor.Commandsendwith;or\g.
Serverversion:5.5.37Sourcedistribution
Copyright(c)2000,2014,Oracleand
/or
itsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand
/or
its
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type
'help;'
or
'\h'
for
help.Type
'\c'
to
clear
thecurrentinputstatement.
MysqL>CREATEDATABASEIFNOTEXISTS`gitlabhq_production`DEFAULTCHARACTERSET`utf8`COLLATE`utf8_unicode_ci`;
QueryOK,1rowaffected(0.00sec)
MysqL>GRANTSELECT,LOCKTABLES,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTERON`gitlabhq_production`.*TO
'git'
@
'localhost'
IDENTIFIEDBY
'gitpasswd'
;
QueryOK,0rowsaffected(0.00sec)
MysqL>flushprivileges;
QueryOK,0rowsaffected(0.01sec)
+------+-----------+-------------------------------------------+
|user|host|password|
+------+-----------+-------------------------------------------+
|root|localhost|*B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB|
|root|127.0.0.1|*B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB|
|git|localhost|*6EA0EDE421A05E610ADBFC5D47B93B6E06C6216F|
+------+-----------+-------------------------------------------+
3rows
in
set
(0.00sec)
|
@H_742_301@
[root@gitlab~]
#MysqL-ugit-p-hlocalhost
Enterpassword:
#这里的密码是上文中给定的gitpasswd
WelcometotheMysqLmonitor.Commandsendwith;or\g.
Serverversion:5.5.37Sourcedistribution
Copyright(c)2000,Oracleand
/or
itsaffiliates.Allrightsreserved.
OracleisaregisteredtrademarkofOracleCorporationand
/or
its
affiliates.Othernamesmaybetrademarksoftheirrespective
owners.
Type
'help;'
or
'\h'
for
help.Type
'\c'
to
clear
thecurrentinputstatement.
MysqL>showdatabases;
+---------------------+
|Database|
+---------------------+
|information_schema|
|gitlabhq_production|
|
test
|
+---------------------+
3rows
in
set
(0.00sec)
安装redis 及 配置redis
安装redis
[root@gitlab~]
#chkconfigredison
[root@gitlab~]
#/etc/init.d/redisstart
Startingredis-server:[OK]
[root@gitlab~]
#netstat-anpt|grepredis
tcp00127.0.0.1:63790.0.0.0:*LISTEN8755
/redi
九、安装gitlab
[root@gitlab~]
#cd/home/git/
[root@gitlabgit]
#sudo-ugit-Hgitclonehttps://gitlab.com/gitlab-org/gitlab-ce.git-b7-4-stablegitlab
Cloninginto
'gitlab'
...
remote:Countingobjects:127971,
done
.
remote:Compressingobjects:100%(32073
/32073
),
done
.
remote:Total127971(delta97845),reused123442(delta94050)
Receivingobjects:100%(127971
/127971
),81.35MiB|1.63MiB
/s
,
done
.
Resolvingdeltas:100%(97845
/97845
),
done
.
Checkingconnectivity...
done
.
[root@gitlabgit]
#cdgitlab/
[root@gitlabgitlab]
#sudo-ugit-Hcpconfig/gitlab.yml.exampleconfig/gitlab.yml
#下面这条命令可以不用操作,保持默认即可
[root@gitlabgitlab]
#sudo-ugit-Hvimconfig/gitlab.yml
gitlab:
##Webserversettings(note:hostistheFQDN,donotincludehttp://)
port:80
https:
false
#修改相应的目录权限
[root@gitlabgitlab]
#chown-Rgitlog/
[root@gitlabgitlab]
#chown-Rgittmp/
[root@gitlabgitlab]
#chmod-Ru+rwXlog/
[root@gitlabgitlab]
#chmod-Ru+rwXtmp/
[root@gitlabgitlab]
#chmod-Ru+rwXtmp/pids/
[root@gitlabgitlab]
#chmod-Ru+rwXtmp/sockets/
[root@gitlabgitlab]
#chmod-Ru+rwXpublic/uploads
#创建目录
[root@gitlabgitlab]
#sudo-ugit-Hmkdir/home/git/gitlab-satellites
[root@gitlabgitlab]
#chmodu+rwx,g=rx,o-rwx/home/git/gitlab-satellites
编辑配置文件unicorn.rb
[root@gitlabgitlab]
#sudo-ugit-Hcpconfig/unicorn.rb.exampleconfig/unicorn.rb
[root@gitlabgitlab]
#nproc
1
[root@gitlabgitlab]
#sudo-ugit-Hvimconfig/unicorn.rb
worker_processes1
#复制配置文件rack_attack.rb
[root@gitlabgitlab]
#sudo-ugit-Hcpconfig/initializers/rack_attack.rb.exampleconfig/initializers/rack_attack.rb
#定义全局的用户和邮箱
[root@gitlabgitlab]
#sudo-ugit-Hgitconfig--globaluser.name"GitLab"
[root@gitlabgitlab]
#sudo-ugit-Hgitconfig--globaluser.email"gitlab@weyee.com"
[root@gitlabgitlab]
#sudo-ugit-Hgitconfig--globalcore.autocrlfinput
#编辑连接redis的配置
[root@gitlabgitlab]
#sudo-ugit-Hcpconfig/resque.yml.exampleconfig/resque.yml
[root@gitlabgitlab]
#sudo-ugit-Hvimconfig/resque.yml
development:redis:
//localhost
:6379
test
:redis:
//localhost
:6379
production:unix:
/var/run/redis/redis
.sock
[root@gitlabgitlab]
#sudo-ugitcpconfig/database.yml.MysqLconfig/database.yml
[root@gitlabgitlab]
#sudo-ugit-Hvimconfig/database.yml
production:
adapter:MysqL2
encoding:utf8
collation:utf8_general_ci
reconnect:
false
database:gitlabhq_production
pool:10
username:git
password:
"gitpasswd"
[root@gitlabgitlab]
#sudo-ugit-Hchmodo-rwxconfig/database.yml
十一、安装gem
#添加淘宝的ruby源
[root@gitlabgitlab]
#sudo-ugitvimGemfile
source
"https://ruby.taobao.org"
#将第一行修改成taobao的源
gitlab]
#sudo-ugitvimGemfile
.lock
remote: https://ruby.taobao.org/:wq:wq
[root@gitlabgitlab]
#cd/home/git/gitlab
[root@gitlabgitlab]
#ln-s/usr/local/bin/bundle/usr/bin/
[root@gitlabgitlab]
#sudo-ugit-Hbundleinstall--deployment--withoutdevelopmenttestpostgresaws
Results logged to
/home/git/gitlab/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/charlock_holmes-0.6.9.4/gem_make.out
An error occurred while installing charlock_holmes (0.6.9.4),and Bundler cannot continue.
Make sure that `gem install charlock_holmes -v '0.6.9.4'` succeeds before bundling.
解决 错误
gem list
看看 是不是已经装了 版本不一样
charlock_holmes-0.6.9.4
卸载到 gem uninstall charlock_holmes
安装
sudo gem install charlock_holmes -v '0.6.9.4' Gem files will remain installed in /home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/MysqL2-0.3.16 for inspection. Results logged to /home/git/gitlab/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/MysqL2-0.3.16/gem_make.out An error occurred while installing MysqL2 (0.3.16),and Bundler cannot continue. Make sure that `gem install MysqL2 -v '0.3.16'` succeeds before bundling.
MysqL2 错误
Make sure that `gem install MysqL2 -v '0.3.16'` succeeds before bundling.
gem install MysqL2 -v '0.3.16'`
yum install MysqL-devel
十二、安装gitlab-shell
[root@gitlabgitlab]
#ln-s/usr/local/bin/ruby/usr/bin/ruby
[root@gitlabgitlab]
# sudo-ugit-Hbundleexecrakegitlab:shell:install[v2.0.1]REDIS_URL=unix:/var/run/redis redis.sockRAILS_ENV=production
gitclone
'https://gitlab.com/gitlab-org/gitlab-shell.git'
'/home/git/gitlab-shell/'
Cloninginto
'/home/git/gitlab-shell'
...
remote:Countingobjects:2118,
done
.
remote:Compressingobjects:100%(1639
/1639
),
done
.
remote:Total2118(delta1301),reused710(delta400)
Receivingobjects:100%(2118
/2118
),306.39KiB|177.00KiB
/s
,
done
.
Checkingconnectivity...
done
.
gitreset--hard$(gitdescribev2.0.1||gitdescribeorigin
/v2
.0.1)||gitfetchorigin&&gitreset--hard$(gitdescribev2.0.1||gitdescribeorigin
/v2
.0.1)
HEADisnowata3b5445Fixbugwhenchangestopost-receiveworkerwasnotdumpedproperly
HEADisnowata3b5445Fixbugwhenchangestopost-receiveworkerwasnotdumpedproperly
bin
/install
mkdir
-p
/home/git/repositories/
:OK
mkdir
-p
/home/git/
.
ssh
:OK
chmod
700
/home/git/
.
ssh
:OK
touch
/home/git/
.
ssh
/authorized_keys
:OK
chmod
600
/home/git/
.
ssh
/authorized_keys
:OK
chmod
-Rug+rwX,o-rwx
/home/git/repositories/
:OK
find
/home/git/repositories/
-
type
d-
exec
chmod
g+s{};:OK
[root@gitlabgitlab]
#sudo-ugit-Hvim/home/git/gitlab-shell/config.yml
---
user:git
gitlab_url:https:
//localhost/
#使用https
http_settings:
repos_path:
"/home/git/repositories/"
auth_file:
"/home/git/.ssh/authorized_keys"
redis:
bin:
"/usr/bin/redis-cli"
namespace:resque:gitlab
socket:
"/var/run/redis/redis.sock"
log_level:INFO
audit_usernames:
false
十三、初始化数据库
[root@gitlabgitlab]
#sudo-ugit-Hbundleexecrakegitlab:setupRAILS_ENV=production
Thiswillcreatethenecessarydatabasetablesandseedthedatabase.
Doyouwantto
continue
(
yes
/no
)?
yes
#输入yes
十四、下载服务脚本
[root@gitlabgitlab]
#wget-O/etc/init.d/gitlabhttps://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn
#配置gitlab的启动级别
[root@gitlabgitlab]
#chmod+x/etc/init.d/gitlab
[root@gitlabgitlab]
#chkconfig--addgitlab
[root@gitlabgitlab]
#chkconfiggitlabon
#配置logrotate
[root@gitlabgitlab]
#cplib/support/logrotate/gitlab/etc/logrotate.d/gitlab
#检测gitlab的应用支持状态,并配置
[root@gitlabgitlab]
#sudo-ugit-Hbundleexecrakegitlab:env:infoRAILS_ENV=production
Systeminformation
System:
CurrentUser: git
UsingRVM: no
RubyVersion: 2.1.2p95
GemVersion: 2.2.2
BundlerVersion:1.9.7
RakeVersion: 10.3.2
SidekiqVersion:2.17.0
GitLabinformation
Version: 7.4.5
Revision: 19d572e
Directory:
/home/git/gitlab
DBAdapter: MysqL2
URL: http:
//localhost
HTTPCloneURL: http:
//localhost/some-project
.git
SSHCloneURL: git@localhost:some-project.git
UsingLDAP: no
UsingOmniauth: no
GitLabShell
Version: 2.0.1
Repositories:
/home/git/repositories/
Hooks:
/home/git/gitlab-shell/hooks/
Git:
/usr/bin/git
[root@gitlabgitlab]
#sudo-ugit-Hbundleexecrakeassets:precompileRAILS_ENV=production
#启动gitlab服务
[root@gitlabgitlab]
#servicegitlabstart
Startingunicorn:[OK]
Startingsidekiq:[OK]
十五、安装Nginx服务,并下载gitlab的站点配置文件
这里的Nginx使用yum进行安装
[root@gitlabgitlab]
#yuminstall-yNginx
No package Nginx available. 解决:
http://blog.chinaunix.net/uid-29612873-id-4226804.html
[root@gitlabgitlab]
#chkconfigNginxon
[root@gitlabgitlab]
#wget-O/etc/Nginx/conf.d/gitlab.confhttps://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/Nginx/gitlab-ssl
[root@gitlabgitlab]
#usermod-a-GgitNginx
[root@gitlabgitlab]
#chmodg+rx/home/git/
[root@gitlabgitlab]
#vim/etc/Nginx/conf.d/gitlab.conf
server_name www.gitlab.com
十六、Gitlab配置SMTP邮件
cd
/home/git/gitlab
[root@gitgitlab]
#sudo-ugit-Hcpconfig/initializers/smtp_settings.rb.sampleconfig/initializers/smtp_setting.rb
#修改如下
[root@gitgitlab]
#sudo-ugit-Hvimconfig/initializers/smtp_settings.rb
if
Rails.
env
.production?
Rails.application.config.action_mailer.delivery_method=:smtp
ActionMailer::Base.smtp_settings={
address:
"smtp.163.com"
,
port:25,
password:
"xxxx"
,
#密码
domain:
"163.com"
,
authentication::login,
enable_starttls_auto:
true
,
#openssl_verify_mode:'peer'#SeeActionMailerdocumentationforotherpossibleoptions
}
end
#编辑文件
[root@gitgitlab]
#sudo-ugit-Hvimconfig/environments/production.rb