nginx + MySQLな環境にgitlabをインストールする

yum install -y gcc-c++ patch libxslt-devel libxml2-devel git ruby-devel libicu-devel mysql55-devel expect autoexpect
yum --enablerepo=epel install -y redis
gem install bundler -v 1.6.2
gem install rake -v 10.3.1
ln -s /usr/local/bin/rake /usr/bin/rake2.0
service redis start
chkconfig redis on

useradd git
cd /home/git
sudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell
cd gitlab-shell
sudo -u git -H git checkout v1.9.4
sudo -u git -H cp config.yml.example config.yml
sudo -u git -H ruby ./bin/install

sudo -u git -H mkdir /home/git/gitlab-satellites
sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites

sudo -u git -H git config --global user.name  "GitLab" 
sudo -u git -H git config --global user.email "gitlab@localhost" 

/usr/local/bin/bundle install

cd /home/git
sudo -u git git clone https://github.com/gitlabhq/gitlabhq gitlab
cd gitlab
sudo -u git git checkout 6-8-stable
sudo -u git cp config/gitlab.yml.example config/gitlab.yml

sudo chown -R git log/
sudo chown -R git tmp/
sudo chmod -R u+rwX  log/
sudo chmod -R u+rwX  tmp/
sudo -u git cp config/unicorn.rb.example config/unicorn.rb
sudo -u git cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
sudo -u git cp config/database.yml.mysql config/database.yml
mysql -e "CREATE DATABASE gitlabhq_production charset utf8;";
sed -i -e "s/^gem \"pg\"/#gem \"pg\"/g" Gemfile

/usr/local/bin/bundle config build.mysql2 --with-opt-include=/usr/include/mysql --with-opt-lib=/usr/lib64/mysql
sudo -u git mkdir -p /home/git/repositories/root
/usr/local/bin/bundle install

sudo -u git /usr/local/bin/bundle exec /usr/local/bin/rake gitlab:setup RAILS_ENV=production
sudo -u git /usr/local/bin/bundle exec /usr/local/bin/rake assets:precompile RAILS_ENV=production

chmod 0740 /etc/sudoers
vim /etc/sudoers
------------------------------
Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
------------------------------
chmod 0440 /etc/sudoers

chmod o+x /home/git
cp lib/support/nginx/gitlab /etc/nginx/conf.d/gitlab.conf

cp lib/support/init.d/gitlab /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab

vim /etc/init.d/gitlab
------------------------------
# chkconfig: 2345 70 35
------------------------------

chkconfig gitlab on
service gitlab start
service nginx restart

sudo -u git /usr/local/bin/bundle exec /usr/local/bin/rake gitlab:check RAILS_ENV=production