参考文章:http://my.oschina.net/dayatang/blog/161335
wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://fedoraproject.org/static/0608B895.txt rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -ivh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
yum -y update 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
yum install –y python27 python27-devel python-docutils cd /usr/bin/ rm -rf python cp python2.7 python
检查版本:python --version
由于yum命令不兼容python2.7,需修改/usr/bin/yum文件,将第一行由“#!/usr/bin/python”改为“#!/usr/bin/python2.6"
cd /tmp yum -y install git perl-ExtUtils-MakeMaker git clone git://github.com/git/git.git cd /tmp/git/ git checkout v1.8.4 autoconf ./configure -–prefix=/usr/local make && make install rm -rf /tmp/git/ yum erase git ln -s /usr/local/git /usr/bin/git
mkdir /tmp/ruby && cd /tmp/ruby curl –-progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz cd ruby-2.0.0-p247 ./configure make && make install gem install bundler –no-ri –no-rdoc
添加淘宝源
gem sources --remove https://rubygems.org/ gem sources -a http://ruby.taobao.org/
更新rails: gem install rails
adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git su - echo [email protected] > /root/.forward chown root /root/.forward chmod 600 /root/.forward restorecon /root/.forward echo [email protected] > /home/git/.forward chown git /home/git/.forward chmod 600 /home/git/.forward restorecon /home/git/.forward
GitLab shell是一个ssh访问和repository管理软件,专为Gitlab开发。
su - git git clone https://github.com/gitlabhq/gitlab-shell.git cd gitlab-shell git checkout v1.7.0 cp config.yml.example config.yml ./bin/install
GitLab支持MySQL和PostgreSQL,而且还必须安装Redis
mysql -u root -p CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'supersecret'; CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
chkconfig redis --level 235 on service redis start
su - git git clone https://github.com/gitlabhq/gitlabhq.git gitlab cd /home/git/gitlab git checkout 6-3-stable
cp config/gitlab.yml.example config/gitlab.yml sed -i 's|/usr/bin/git|/usr/local/bin/git|' config/gitlab.yml chown -R git log/ chown -R git tmp/ chmod -R u+rwX log/ chmod -R u+rwX tmp/ mkdir /home/git/gitlab-satellites mkdir tmp/pids/ mkdir tmp/sockets/ chmod -R u+rwX tmp/pids/ chmod -R u+rwX tmp/sockets/ mkdir public/uploads chmod -R u+rwX public/uploads cp config/unicorn.rb.example config/unicorn.rb git config --global user.name "GitLab" git config --global user.email "[email protected]" git config --global core.autocrlf input
cp config/database.yml.mysql config/database.yml vim config/database.yml # 修改密码 chmod o-rwx config/database.yml
rpm -ivh /tmp/libicu-devel-4.2.1-9.1.el6_2.x86_64.rpm #需要下载 gem install charlock_holmes --version '0.6.9.4' cd /home/git/gitlab/ bundle install --deployment --without development test postgres puma aws ln -s /usr/local/bin/ruby /usr/bin/ ln -s /usr/local/bin/bundle /usr/bin/bundle
chmod -R 777 /home/git #授权
cd /home/git/gitlab bundle exec rake gitlab:setup RAILS_ENV=production cp config/unicorn.rb.example config/unicorn.rb bundle exec unicorn_rails -c config/unicorn.rb -E production -D
su - cp lib/support/init.d/gitlab /etc/init.d/gitlab chmod +x /etc/init.d/gitlab chkconfig --add gitlab chkconfig gitlab --level 235 on
su - git cd gitlab/ bundle exec rake gitlab:env:info RAILS_ENV=production exit
# yum install nginx
复制配置文件
cp /home/git/gitlab/lib/support/nginx/gitlab /etc/nginx/conf.d/ mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.back mv /etc/nginx/conf.d/gitlab /etc/nginx/conf.d/default.conf
访问:http://{IP} 默认用户名/密码:[email protected]/5iveL!fe
# listen *:99 default_server
# listen "127.0.0.1:9999", :tcp_nopush => true
问题调试
1.cd /home/git/gitlab-shell 执行bin/check
2.cd /home/git/gitlab/执行 bundle exec rake gitlab:check RAILS_ENV=production
bundle exec rake gitlab:env:info RAILS_ENV=production
遇见问题
1.不能clone和push代码,这个升级git解决了
2.Test redis-cli executable: bin/check:35: warning: Insecure world writable dir /home/git in PATH, mode 040777
chmod go-w /home/git