centos 32位下安装gitlab

目前系统的环境
centos6.4 32位
已经安装MysqL Nginx

下载并安装GPG key

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

检验下是否安装成功

rpm -qa gpg*

安装epel-release-6-8.noarch包

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

PS.不要在意x86_64(64位),在i686(32位)的机器上一样能使用

增加PUIAS安装源

vi /etc/yum.repos.d/PUIAS_6_computational.repo

添加如下内容

[PUIAS_6_computational]
name=PUIAS computational 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

下载并安装GPG key

wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springDale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias

安装GitLab的所需依赖包和工具

su -
yum -y groupinstall 'Development Tools'
yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git

配置redis

chkconfig redis on
service redis start

安装Ruby

su -
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz| tar xz
cd ruby-2.3.0
./configure --prefix=/usr/local/
make && make install

PS.安装完成后,重新登录终端确保$PATH生效,检测ruby的安装成功与否:

ruby -v

安装bundle

gem install bundler --no-ri --no-rdoc

创建用户git

adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git

PS.因为git用户不需要登录,所以这里不需要设置git的密码

下载gitlab shell

https://github.com/gitlabhq/gitlab-shell/tree/v2.7.2
我这里用游览器下载的然后传到服务器上,然后修改权限

chmod -R 777 /home/git/gitlab-shell

也可以用git下载,但是比较慢

su - git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout v3.4.0

我这里安装的是2.7.2

配置gitlab shell

cd gitlab-shell
cp config.yml.example config.yml

这里最重要的是将gitlab_url修改成gitlab的访问域名。比如:http://git.PHPsong.com/

修改hosts

vi /etc/hosts

添加

127.0.0.1 git.PHPsong.com

安装一些需要的目录和文件

./bin/install

安装GitLab

下载地址
https://github.com/gitlabhq/gitlabhq/tree/7-14-stable
我这里用游览器下载的然后传到服务器上,然后修改权限

chmod -R 777 /home/git/gitlab

也可以用git下载,但是比较慢

su - git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
git checkout 7-14-stable

配置项目

cd /home/git/gitlab
cp config/gitlab.yml.example config/gitlab.yml
sed -i 's|localhost|git.PHPsong.com|g' config/gitlab.yml

su -
cd /home/git/gitlab
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
chmod -R u+rwX public/uploads

su - git
mkdir /home/git/gitlab-satellites

cd /home/git/gitlab
cp config/unicorn.rb.example config/unicorn.rb

配置数据库访问文件

cp config/database.yml.MysqL config/database.yml
vi config/database.yml

比如我的配置

#
# PRODUCTION
#
production:
  adapter: MysqL2
  encoding: utf8
  collation: utf8_general_ci
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: root
  password: "123456"
  # host: localhost
  # socket: /tmp/MysqL.sock

PS.MysqL的引擎必须是Innodb,myisam的安装会失败,可以用MySQL命令show engines查看

安装Gems

su -
gem install charlock_holmes

初始化数据和激活高级功能

PS.修改gitlab目录下的Gemfile和Gemfile.lock问首行的域名rubygems.org修改成ruby.taobao.org,修改后执行名的命令就会比较快

su - git
cd /home/git/gitlab/
bundle install --deployment --without development test postgres puma aws
bundle exec rake gitlab:setup RAILS_ENV=production

PS.安装的时候出现如下错误

解决方法
安装nodejs http://www.PHPsong.com/2117.html
执行

gem install execjs
gem install therubyracer

安装成功之后会显示用户名和密码
login………root
password……5iveL!fe
在执行下面的命令,不然没有样式

bundle exec rake assets:precompile RAILS_ENV=production

安装启动脚本

su -
wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn
chmod +x /etc/init.d/gitlab
chkconfig --add gitlab
#开机时启动
chkconfig gitlab on

启动GitLab实例

service gitlab start

Nginx配置

su -
cp /home/git/gitlab/lib/support/Nginx/gitlab /usr/local/Nginx/conf/vhost/git.PHPsong.com.conf

修改一下里面的配置

vi /usr/local/Nginx/conf/vhost/git.PHPsong.com.conf
mkdir /var/log/Nginx

里面的内容主要修改端口和域名,如我下面的配置

#  listen 0.0.0.0:80 default_server;
#  listen [::]:80 default_server;
listen 80;
server_name git.PHPsong.com; ## Replace this with something like gitlab.example.com
检查一下Nginx配置
Nginx -t

我这里的Nginx是www的用户启动

ps aux|grep Nginx

将www加入git用户

usermod -a -G git www

PS.如果查看/var/log/Nginx/gitlab_error.log发现错误connect() to unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket Failed错误

解决方法

vi /usr/local/Nginx/conf/vhost/git.PHPsong.com.conf

修改

upstream gitlab-workhorse {
#  server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}

重要错误日志文件

/home/git/gitlab/log/unicorn.stderr.log
/var/log/Nginx/gitlab_error.log

参考网址: http://my.oschina.net/wzlee/blog/262181

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native