Centos6.6搭建GitLab CE

安装软件包
$ yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker


安装Git
// 查看当前git版本
$ git –version
// 如果小于1.7.10则先卸载
$ yum remove git

// 下载最新的git并安装
$ wget -O git-src.zip https://github.com/git/git/archive/master.zip
$ unzip git-src.zip
$ cd git-src
$ make prefix=/usr/local all
$ make prefix=/usr/local install
$ ln -fs /usr/local/bin/git* /usr/bin/


安装Ruby
$ mkdir /tmp/ruby && cd /tmp/ruby
$ curl –progress ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz | tar xz
$ cd ruby-2.1.5
$ ./configure –disable-install-rdoc
$ make && make install

$ 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

$ gem source -r https://rubygems.org/
$ gem source -a https://gems.ruby-china.org/

$ gem install bundler –no-ri –no-rdoc


安装MySQL 初始化GitLab库
$ yum install mysql mysql-devel mysql-server -y
$ /etc/init.d/mysqld start
$ chkconfig mysqld on
// 登录mysql创建gitab的帐号和数据库
mysql> CREATE USER ‘gitlab’@’localhost’ IDENTIFIED BY ‘gitlab’;
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO ‘gitlab’@’localhost’;
//测试是否可以用git帐号登录数据库
$sudo -u git -H mysql -u gitlab -p -D gitlabhq_production


安装Redis
$ yum install -y wget gcc make tcl
$ wget http://download.redis.io/releases/redis-3.2.9.tar.gz
$ tar zxvf redis-3.2.9.tar.gz
$ cd redis-3.2.9
$ make
$ make test
$ make install

$ cp redis.conf /etc/
$ touch /etc/init.d/redis
$ chmod 755 /etc/init.d/redis
$ vi /etc/init.d/redis

#!/bin/bash
#
# Init file for redis
#
# chkconfig: – 80 12
# description: redis daemon
#
# processname: redis
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
#BIN=”/usr/local/bin”
BIN=”/usr/local/bin”
CONFIG=”/etc/redis.conf”
PIDFILE=”/var/run/redis.pid”
### Read configuration
[ -r “$SYSCONFIG” ] && source “$SYSCONFIG”
RETVAL=0
prog=”redis-server”
desc=”Redis Server”
start() {
if [ -e $PIDFILE ];then
echo “$desc already running….”
exit 1
fi
echo -n $”Starting $desc: ”
daemon $BIN/$prog $CONFIG
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
return $RETVAL
}
stop() {
echo -n $”Stop $desc: ”
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
return $RETVAL
}
restart() {
stop
start
}
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
[ -e /var/lock/subsys/$prog ] && restart
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|condrestart|status}”
RETVAL=1
esac
exit $RETVAL

#在redis.conf中修改 #mkdir /data
daemonize yes
logfile “/var/log/redis.log”
dir /data

$ /etc/init.d/redis start
$ chkconfig redis on


添加git帐号并允许sudo
$ useradd –comment ‘GitLab’ git
$ echo “git ALL=(ALL) NOPASSWD: ALL” >>/etc/sudoers


安装GitLab CE配置依赖项
如想使用Postfix来发送邮件,在安装期间请选择’Internet Site’. 您也可以用sendmai或者 配置SMTP服务 并 使用SMTP发送邮件.
在 Centos 6 和 7 系统上, 下面的命令将在系统防火墙里面开放HTTP和SSH端口.
$ sudo yum install curl openssh-server openssh-clients postfix cronie
$ sudo service postfix start
$ sudo chkconfig postfix on
$ sudo lokkit -s http -s ssh


添加GitLab仓库,并安装到服务器上
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
$ sudo yum install gitlab-ce


启动GitLab
$ sudo gitlab-ctl reconfigure


使用浏览器访问GitLab
首次访问GitLab,系统会让你重新设置管理员的密码,设置成功后会返回登录界面.
默认的管理员账号是root,如果你想更改默认管理员账号,请输入上面设置的新密码登录系统后修改帐号名.

composer 报错处理

$composer update
Your requirements could not be resolved to an installable set of packages

执行以下命令得以解决

$composer global require “fxp/composer-asset-plugin:^1.3.1”