equinox79
8/6/2013 - 10:25 AM

install gitlab

install gitlab

su -

#dependcies
#centos 6.2 | http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm

rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm

yum -y groupinstall 'Development Tools' 'Additional Development'

yum -y install 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

#ruby
curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
tar xzvf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
./configure --enable-shared --disable-pthread
make
make install

#install qt4
yum install qt4 qt4-devel qtwebkit-devel
export PATH=$PATH:/usr/lib64/qt4/bin
gem update --system
gem update
gem install rails 

adduser --shell /bin/bash --create-home --home-dir /home/gitlab gitlab

#generate ssh key
su gitlab
ssh-keygen -t rsa # as gitlab user
exit

adduser -r --shell /bin/sh --comment 'gitolite' --create-home --home-dir /home/git git

#permission
usermod -a -G git gitlab  
sudo usermod -a -G gitlab git

#gitolite
# make sure you do this as root
cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub

su git

#getolite
# add sudoer
sudo -H -u git git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite

cd /home/git
sudo -u git -H mkdir bin
sudo -u git sh -c 'echo -e "PATH=\$PATH:/home/git/bin\nexport PATH" >> /home/git/.profile'
sudo -u git sh -c 'gitolite/install -ln /home/git/bin'

sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub

sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"

#permission
chmod -R g+rwX /home/git/repositories/  
chmod 770 /home/git

# clone admin repo to add localhost to known_hosts
# & be sure your user has access to gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin

# if succeed  you can remove it
sudo rm -rf /tmp/gitolite-admin


passwd gitlab # please choose a good password :)

#make gitlab sudoer
visudo
# find: root    ALL=(ALL)    ALL
# and add
gitlab    ALL=(ALL)    ALL

#python
curl http://python-distribute.org/distribute_setup.py | python  

#install pip
wget --no-check-certificate http://pypi.python.org/packages/source/p/pip/pip-0.7.2.tar.gz
tar xzf pip-0.7.2.tar.gz
cd pip-0.7.2
python setup.py install

pip install pygments  
gem install bundler 

#more gems!!!
gem install ruby-debug19
#gem install charlock_holmes
gem install charlock_holmes --version '0.6.9'
#pg headers and gem
#wget http://yum.postgresql.org/9.1/redhat/rhel-5-x86_64/pgdg-centos91-9.1-4.noarch.rpm
wget http://yum.postgresql.org/9.1/redhat/rhel-5Server-x86_64/pgdg-redhat91-9.1-5.noarch.rpm
#rpm -i pgdg-centos91-9.1-4.noarch.rpm
rpm -ivh pgdg-redhat91-9.1-5.noarch.rpm
yum install postgresql-devel
PATH=/usr/pgsql-9.1/bin:$PATH
gem install pg

#mysql
yum -y install mysql-server mysql-devel
/etc/init.d/mysqld start
mysql_secure_installation
mysql -u root -p # when prompted enter the root password you've chosen in mysql_secure_installation

mysql> CREATE DATABASE gitlab CHARACTER SET UTF8;  
mysql> GRANT ALL PRIVILEGES ON gitlab.* TO 'gitlabusr'@'localhost' IDENTIFIED BY 'supersecret' WITH GRANT OPTION;  
mysql> quit 

gem install mysql2 -v '0.3.11'

#install gitlab
cd /home/gitlab

#stable
#sudo -H -u gitlab git clone -b stable https://github.com/gitlabhq/gitlabhq.git gitlab
sudo -H -u gitlab git clone https://github.com/gitlabhq/gitlabhq.git gitlab

cd gitlab

# Rename config files
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml

# Copy mysql db config
# make sure to update username/password in config/database.yml change all users to root & password
sudo -u gitlab cp config/database.yml.mysql config/database.yml

# Copy unicorn config
sudo -u gitlab cp config/unicorn.rb.example config/unicorn.rb

#as gitlab
cd ~/gitlabhq

before you rake it edit Gem lock file and look for rake(10.0.1) and change to 10.0.2

RAILS_ENV=production rake db:setup
RAILS_ENV=production rake db:seed_fu

exit
#disable firewall or you can configure it if you want, as root
service iptables save
service iptables stop
chkconfig iptables off
exit

#as gitlab
sudo gem install pg -v '0.15.1' -- --with-pg-dir=/usr/pgsql-9.1
bundle install

# edit config
# db, user

service redis start


bundle exec rails s -e production

celebrate!