1.安装依赖库

yum install libicu-devel mysql-develpcre-devel

安装python,官方要求版本必须在2.5以上,而且不支持3.0,而CentOS5.5默认的Python版本是2.4的,此时就需要手动升级Python

下载python版本

wget -c http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz

编译安装python  

tar -zxvfPython-3.3.0.tgz

cd Python-3.3.0

./configure

make all

make install

清除之前编译的可执行文件及配置文件

make clean

清除所有生成的文件

make distclean

查看python版本信息

/usr/local/bin/python3 –V


spacer.gif

将之前版本的python备份

mv python python.old

将编译安装的python建立软连接

ln -s /usr/local/bin/python3.3 /usr/bin/python

保证之前python2也可以使用

ln -s /usr/bin/python /usr/bin/python2

安装Ruby

mkdir /tmp/ruby && cd/tmp/ruby

curl--progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tarxz
cd ruby-1.9.3-p392
./configure
make
make install

RVM方式

curl -#L https://get.rvm.io | bash-s stable --ruby

注:如果安装的时候出现failedFile "/usr/bin/yum", line 30except KeyboardInterrupt, e:,就需要将/usr/bin/yum里面的第一行"#!/usr/bin/python"改为 "#!/usr/bin/python2.4",修改之后重新执行命令。

这里可能需要等好长时间了。

执行完成之后需要执行以下命令

rvm install ruby-1.9.3-p392

注:如果执行的时候报错,那么需要执行source/usr/local/rvm/scripts/rvm

然后再去重新执行rvm方式

rvm install ruby-1.9.3-p392

安装bundler

gem install bundler

添加git用户

adduser --comment 'GitLab' git

git用户无密码登陆

chmod 644 /etc/shadow

vi /etc/shadow

删掉感叹号:

git:!!:15814:0:99999:7::: 修改为 git::15814:0:99999:7:::

git用户加入到sudo

chmod u+w /etc/sudoers

vi /etc/sudoers


## Allow root to run any commands  anywhere

root ALL=(ALL) ALL

git ALL=(ALL)  NOPASSWD:ALL #加入这行#

# %wheel ALL=(ALL) NOPASSWD:ALL 改为

%wheel ALL=(ALL) NOPASSWD:ALL


现在切换git用户

su  - git

安装依赖包

sudo yum install zlib-devel

sudo yum install openssl-devel

sudo yum install perl

sudo yum install cpio

sudo yum install expat-devel

sudo yum install gettext-devel

sudo yum install gcc


安装Curlroot用户)


tar xzvf curl-7.18.0.tar.gz

cd curl-7.18.0

./configure

make

sudo make install


确定一下ld.so.conf文件里有/usr/local/lib,这个是为git-http-push准备的.

sudo vi /etc/ld.so.conf

#插入下面的代码

/usr/local/lib

保存文件,接着运行:

sudo /sbin/ldconfig

下载git并安装

根据这个网址http://code.google.com/p/git-core/downloads/list最新的版本是1.8.5.2

tar xzvf git-latest.tar.gz

cd git-1.8.5.2

autoconf(如果终端提示no command的话就yum install autoconf,千万不要以为文件夹中有makefile就好直接make了,不然会出错的)

./configure --with-curl=/usr/local

make

sudo make install

克隆GitLab Shell

git clone git://github.com/gitlabhq/gitlab-shell.git

cd gitlab-shell

git checkout v1.1.0

git checkout -b v1.1.0

生产配置文件

cp config.yml.example config.yml

更改配置信息,一般就改下你部署的域名地址gitlab_url

vi config.yml


# Url to gitlab instance. Used for api calls. Shouldbe ends with slash.

gitlab_url: "http://localhost/" #改成你的域名或者IP

安装

./bin/install

切换回root用户安装数据库

yum install -y mysql-server mysqlmysql-devel

启动数据库

service mysqld start

初始化GitLab数据库




mysql -u root -p

Enter password: (直接按回车键)

Welcome to the MySQL monitor.

Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.30 MySQL Community  Server (GPL)


Copyright (c) 2000, 2013, Oracle and/or  its affiliates. All rights reserved.


Oracle is a registered trademark of  Oracle Corporation and/or its affiliates. Other names may be trademarks of  their respective owners.


Type 'help;' or '\h' for help. Type '\c'  to clear the current input statement.


mysql> CREATE USER 'gitlab'@'localhost'  IDENTIFIED BY 'gitlab';

Query OK, 0 rows affected (0.01 sec)


mysql> CREATE DATABASE IF NOT EXISTS  `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

Query OK, 1 row affected (0.00 sec)


mysql> GRANT SELECT, LOCK  TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON  `gitlabhq_production`.* TO 'gitlab'@'localhost';

Query OK, 0 rows affected (0.00 sec)


mysql> exit

Bye

测试gitlab用户连接mysql

sudo -u git -H mysql -u gitlab -p-D gitlabhq_production

Enter password:gitlab

测试通过,连接成功

终于到GitLab的安装了,进入git用户

su - git

克隆GitLab

sudo -u git -H git clonehttps://github.com/gitlabhq/gitlabhq.git gitlab

克隆出现error,需要执行这条命令,关闭全局证书验证

git config --global http.sslverifyfalse

sudo -u git -H git clonehttps://github.com/gitlabhq/gitlabhq.git gitlab
cdgitlab

切换到5.0稳定分支

sudo -u git -H git checkout5-0-stable


配置

cd /home/git/gitlab


# 用样例配置生成gitlab配置

sudo -u git -H cp config/gitlab.yml.exampleconfig/gitlab.yml


# 更改域名

sudo -u git -H vimconfig/gitlab.yml


# 确保gitlab log/ tmp/ 目录有写权限

sudo chown -R git log/

sudo chown -R git tmp/

sudo chmod -R u+rwX log/

sudo chmod -R u+rwX tmp/


创建附属目录

sudo -u git -H mkdir /home/git/gitlab-satellites


# 创建pids目录并确保对gitlab可写

sudo -u git -H mkdir tmp/pids/

sudo chmod -R u+rwX tmp/pids/


# 生成Unicorn配置

sudo -u git -H cp config/unicorn.rb.exampleconfig/unicorn.rb

配置GitLab DB设置

# sudo -u git cp config/database.yml.mysqlconfig/database.yml

安装Gems

cd /home/git/gitlab

sudo geminstall charlock_holmes --version '0.6.9'

安装的时候一直报错,说什么要我安装libyaml以及重新安装ruby,

Installing libyaml

$ wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
$ tar xzvf yaml-0.1.4.tar.gz
$ cd yaml-0.1.4
$ ./configure --prefix=/usr/local
$ make

$ make install

我勒个去。我都安装n遍了,最后查找官方的文档,说是ruby要禁掉二进制安装,按照这个重新安装了ruby,但是在执行最后一部rake的时候又报同样的错。最后楼主发现了gitlab一键安装包,在编译安装整了两天多难以进行的情况下,果断卸掉之前的应用,使用一键安装包安装成功。

那位如果编译安装成功了,请告知我报错处理的方法。谢谢啦。

时间紧,截图神马的都是浮云,就不提了。