CentOS 6.6源码安装GitLab7

环境:CentOS-6.6-x86_64-minimal.iso

安装LNMP(必须安装Nginx、MySQL、redis,PHP可选),参考《lnmp一键安装包》或《OneinStack》

添加epel仓库

  1. cat > /etc/yum.repos.d/epel.repo << EOF
  2. [epel]
  3. name=Extra Packages for Enterprise Linux 6 – \$basearch
  4. #baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
  5. mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=\$basearch
  6. failovermethod=priority
  7. enabled=1
  8. gpgcheck=0
  9. EOF

添加PUIAS Computational参考(自带的git版本是1.7和gitlab不兼容)

  1. cat > /etc/yum.repos.d/PUIAS_6_computational.repo << EOF
  2. [PUIAS_6_computational]
  3. name=PUIAS computational Base \$releasever – \$basearch
  4. mirrorlist=http://puias.math.ias.edu/data/puias/computational/\$releasever/\$basearch/mirrorlist
  5. #baseurl=http://puias.math.ias.edu/data/puias/computational/\$releasever/\$basearch
  6. enabled=1
  7. gpgcheck=0
  8. EOF

安装依赖包

  1. yum -y install vim-enhanced readline readline-devel ncurses-devel \
  2. gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel \
  3. db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi \
  4. libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel \
  5. system-config-firewall-tui python-devel crontabs logwatch \
  6. logrotate perl-Time-HiRes git

Ruby安装

  1. cd lnmp/src
  2. wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz
  3. tar xzf ruby-2.1.5.tar.gz
  4. cd ruby-2.1.5
  5. ./configure –prefix=/usr/local/ruby
  6. make && make install
  7. cd ..

添加到环境变量

  1. vi /etc/profile
  2. export PATH=/usr/local/ruby/bin:$PATH
  3. . /etc/profile

安装Bundler Gem

  1. gem install bundler –no-ri –no-rdoc

为GitLab创建一个git用户

  1. adduser –system –shell /bin/bash –comment ‘GitLab’ –create-home –home-dir /home/git/ git
  2. su – git

GitLab shell安装

  1. git clone https://github.com/gitlabhq/gitlab-shell.git
  2. cd gitlab-shell
  3. git checkout v1.8.0
  4. cp config.yml.example config.yml
  5. sed -i ‘s@http://localhost/@http://git.linuxeye.com/@’ config.yml
  6. sed -i ‘s@/usr/bin/redis-cli@/usr/local/redis/bin/redis-cli@’ config.yml
  7. ./bin/install

数据库/MySQL

  1. $ mysql -uroot -p
  2. mysql> create database gitlabhq_production;
  3. mysql> quit;

redis.sock路径指定

  1. su –
  2. service redis-server stop
  3. mkdir /var/run/redis;chown -R redis.redis /var/run/redis
  4. vi /usr/local/redis/etc/redis.conf
  5. unixsocket /var/run/redis/redis.sock
  6. service redis-server start
  7. ls -l /var/run/redis/redis.sock

GitLab

  1. su – git
  2. wget https://github.com/gitlabhq/gitlabhq/archive/v7.4.5.tar.gz
  3. tar xzvf v7.4.5.tar.gz
  4. mv gitlabhq-7.4.5 gitlab
  5. cd gitlab
  6. cp config/gitlab.yml.example config/gitlab.yml
  7. sed -i ‘s@[email protected]@g’ config/gitlab.yml
  8. chown -R git log/
  9. chown -R git tmp/
  10. chmod -R u+rwX  log/
  11. chmod -R u+rwX  tmp/
  12. mkdir /home/git/gitlab-satellites
  13. mkdir tmp/pids/
  14. mkdir tmp/sockets/
  15. chmod -R u+rwX  tmp/pids/
  16. chmod -R u+rwX  tmp/sockets/
  17. mkdir public/uploads
  18. chmod -R u+rwX  public/uploads
  19. cp config/unicorn.rb.example config/unicorn.rb
  20. git config –global user.name “GitLab”
  21. git config –global user.email “[email protected]
  22. git config –global core.autocrlf input
  23. cp config/resque.yml.example config/resque.yml

GitLab数据库配置

  1. cp config/database.yml{.mysql,}
  2. cat config/database.yml
  3. production:
  4.   adapter: mysql2
  5.   encoding: utf8
  6.   collation: utf8_general_ci
  7.   reconnect: false
  8.   database: gitlabhq_production
  9.   pool: 10
  10.   username: root
  11.   password: “password”
  12.   # host: localhost
  13.   # socket: /tmp/mysql.sock
  14. chmod o-rwx config/database.yml

Gems安装

  1. su –
  2. gem install charlock_holmes –version ‘0.6.9.4’
  3. exit
  4. cd /home/git/gitlab/
  5. bundle install –deployment –without development test postgres puma aws postgres

GitLab shell安装

  1. bundle exec rake gitlab:shell:install[v2.1.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
  2. vi /home/git/gitlab-shell/config.yml
  3. 修改正确路径,如redis-cli,路径改成bin: “/usr/local/bin/redis-cli”
  4. restorecon -Rv /home/git/.ssh

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

  1. git init
  2. bundle exec rake gitlab:setup RAILS_ENV=production #yes
  3. login………root
  4. password……5iveL!fe

GitLab初始化脚本

  1. su –
  2. wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn
  3. chmod +x /etc/init.d/gitlab
  4. chkconfig –add gitlab
  5. chkconfig gitlab on
  6. exit #切回git用户

检查应用状态

  1. cd /home/git/gitlab/
  2. bundle exec rake gitlab:env:info RAILS_ENV=production

Compile assets

  1. bundle exec rake assets:precompile RAILS_ENV=production

GitLab启动

  1. su –
  2. service gitlab start

Nginx配置

  1. usermod -a -G git www
  2. chmod 770 /home/git
  3. mkdir /usr/local/nginx/conf/vhost
  4. cd /usr/local/nginx/conf/vhost
  5. wget -O git.linuxeye.com.conf https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab-ssl
  6. vi git.linuxeye.com.conf #修改一下配置项
  7. root /home/git/gitlab/public;
  8. server_name
  9. access_log
  10. error_log
  11. ssl_certificate gitlab.crt;
  12. ssl_certificate_key gitlab.key;

ps:证书生成方法如下(正式环境建议将生成公钥用第三方签名使浏览器能识别):

  1. cd /usr/local/nginx/conf
  2. openssl genrsa -out gitlab.key 2048
  3. openssl req -new -x509 -days 36500 -key gitlab.key -out gitlab.crt -subj “/C=CN/ST=Shanghai/L=Shanghai/O=LinuxEye Ltd./OU=LinuxEye

重启nginx

  1. service nginx restart

访问:https://git.linuxeye.com,用户名/密码:root/5iveL!fe

参考:https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos

Mon Mar 2 10:47:45 CST 2015

【AD】美国洛杉矶CN2 VPS/香港CN2 VPS/日本CN2 VPS推荐,延迟低、稳定性高、免费备份_搬瓦工vps

【AD】RackNerd 推出的 KVM VPS 特价优惠,在纽约、西雅图、圣何塞和阿什本每年仅需 12.88 美元!