原文链接:https://www.f2er.com/centos/379139.html目前系统的环境
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.rpmPS.不要在意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 installPS.安装完成后,重新登录终端确保$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/ gitPS.因为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/hosts127.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.rbcp 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.sockPS.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=productionPS.安装的时候出现如下错误
解决方法
安装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 startNginx配置
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 -tps aux|grep Nginx将www加入git用户组
usermod -a -G git wwwPS.如果查看/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