Redhat release software collection January this year. It’s kind of cool as it lets you install newer versions of ruby perl python etc. Gitlab requires version ruby193 which is very easy to install with scl. This install guide is based on the original gitlab install guide which can be found here “https://github.com/gitlabhq/gitlab-recipes” and shows you howto make gitlab work with SCL instead of RVM.
Step 1. Add the SCL repo to your Rhel/Centos installation
http://people.redhat.com/bkabrda/scl_ruby193.repo
[scl_ruby193] name=Ruby 1.9.3 Dynamic Software Collection baseurl=http://people.redhat.com/bkabrda/ruby193-rhel-6/ failovermethod=priority enabled=1 gpgcheck=0
Make sure you are also subscribed to the rhel6-server optional channel. Then install the Development tools
# yum -y groupinstall 'Development Tools' ### 'Additional Development' # yum -y install vim-enhanced httpd 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 mysql-server wget \ mysql-devel crontabs logwatch logrotate sendmail-cf qtwebkit qtwebkit-devel \ perl-Time-HiRes libicu-devel libxml2-devel libxslt-devel mysql-devel
Step 2. As rhel still ships with git version 1.7.1-3.el6_4.1 we also need to add the rpm forge package
# yum localinstall -y http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Enable the rpmforge extras
Step 3. Gitlab also needs redis which is available on epel.
# yum localinstall -y http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Step 4. Lets install ruby193 and git httpd mysql-server and start all the servies
# yum install -y ruby193 ruby193-ruby-devel git redis httpd mysql-server # service mysqld start # service redis start # service httpd start # chkconfig mysqld on # chkconfig redis on # chkconfig httpd on
Step 5. Add the user git and set the git globals
# adduser -r -s /bin/bash -c 'Gitlab user' -m -d /home/git git # su - git [git@gitlab ~]$ git config --global user.name "GitLab" [git@gitlab ~]$ git config --global user.email "gitlab@localhost"
Step 6. su to the git user to clone the git repos
# su - git [git@gitlab ~]$ git clone https://github.com/gitlabhq/gitlab-shell.git [git@gitlab ~]$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
Step 7. Extend your .bashrc to have the following content which will load our scl environment for us when we login
# .bashrc # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi LD_LIBRARY_PATH=/opt/rh/ruby193/root/usr/lib64: PATH=/opt/rh/ruby193/root/usr/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/git/bin export PATH export LD_LIBRARY_PATH
Step 8. Make sure the paths are right. You can test this by executing env.
Step 9. Logout and login again as user gitlab. If everything went fine you should be able to do this
[git@gitlab ~]$ which ruby /opt/rh/ruby193/root/usr/bin/ruby [git@gitlab ~]$ ruby --version ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
Step 10. As git cd into the git-shell dir and checkout version 1.4
[git@gitlab ~]$ cd gitlab-shell/ [git@gitlab gitlab-shell]$ git checkout v1.4.0 Note: checking out 'v1.4.0'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at 8343298... Fix tests and version up to 1.4.0 [git@gitlab gitlab-shell]$
Step 11. Copy the file config.yml.example to config.yml and and replace the hostname localhost with your hostname
[git@gitlab gitlab-shell]$ sed -i 's/localhost/gitlab.local.domb.com/g' config.yml
Step 12. Install gitshell
git@gitlab gitlab-shell]$ ./bin/install mkdir -p /home/git/repositories: true mkdir -p /home/git/.ssh: true chmod 700 /home/git/.ssh: true touch /home/git/.ssh/authorized_keys: true chmod 600 /home/git/.ssh/authorized_keys: true chmod -R ug+rwX,o-rwx /home/git/repositories: true find /home/git/repositories -type d -print0 | xargs -0 chmod g+s: true
Step 13. IMPORTANT. Do this still as the git user! checkout gitlab 5.2
[git@gitlab ~]$ cd gitlab [git@gitlab gitlab]$ ls app CONTRIBUTING.md Gemfile.lock MAINTENANCE.md script Capfile.example db Guardfile Procfile spec CHANGELOG doc lib public tmp config features LICENSE Rakefile vendor config.ru Gemfile log README.md VERSION [git@gitlab gitlab]$ git checkout 5-2-stable Branch 5-2-stable set up to track remote branch 5-2-stable from origin. Switched to a new branch '5-2-stable'
Step 14. Lets configure Gitlab and install the gems
[git@gitlab gitlab]$ gem install bundler Fetching: bundler-1.3.5.gem (100%) Successfully installed bundler-1.3.5 1 gem installed Installing ri documentation for bundler-1.3.5... Installing RDoc documentation for bundler-1.3.5. [git@gitlab gitlab]$ gem install charlock_holmes --version '0.6.9.4' Building native extensions. This could take a while... .... ...................... . Successfully installed charlock_holmes-0.6.9.4 1 gem installed Installing ri documentation for charlock_holmes-0.6.9.4... Installing RDoc documentation for charlock_holmes-0.6.9.4...
Step 15. Configure Gitlab
Copy the example GitLab config and edit the necessary fields.
[git@gitlab gitlab]$ cp /home/git/gitlab/config/gitlab.yml{.example,} [git@gitlab gitlab]$ sed -i 's/localhost/gitlab.local.domb.com/g' /home/git/gitlab/config/gitlab.yml [git@gitlab gitlab]$ chown -R git /home/git/gitlab/log/ [git@gitlab gitlab]$ chown -R git /home/git/gitlab/tmp/ [git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/log/ [git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/tmp/ [git@gitlab gitlab]$ mkdir /home/git/gitlab-satellites [git@gitlab gitlab]$ mkdir /home/git/gitlab/tmp/pids/ [git@gitlab gitlab]$ mkdir /home/git/gitlab/tmp/sockets/ [git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/tmp/pids/ [git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/tmp/sockets/ [git@gitlab gitlab]$ mkdir /home/git/gitlab/public/uploads [git@gitlab gitlab]$ chmod -R u+rwX /home/git/gitlab/public/uploads
Step 16. Copy the puma.rb config and configure it. Change the bind parameter so that it reads: bind ‘tcp://127.0.0.1:9292’
Step 17. Confugre Mysql and change the user and password in the database.yml file
production: adapter: mysql2 encoding: utf8 reconnect: false database: gitlabhq_production pool: 5 username: gitlab password: "iloveopensource" # host: localhost # socket: /tmp/mysql.sock
Step 18. Create a Mysql User
[git@gitlab gitlab]$ mysql -u root # Create a user for GitLab. (change supersecret to a real password) CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'iloveopensource'; # Create the GitLab production database CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; # Grant the GitLab user necessary permissions on the table. GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
Step 19. Check if you can login as the gitlab user
[git@gitlab gitlab]$ mysql -u gitlab -p -D gitlabhq_production
Step 20. Secure MySQL by entering a root password and say “Yes” to all questions with the next command
# /usr/bin/mysql_secure_installation
Step 21. Add this as your apache config in /etc/httpd/conf.d/gitlab.conf
ServerName gitlab.local.domb.com ProxyRequests Off Order deny,allow Allow from all ProxyPreserveHost On ProxyPass / http://localhost:9292/ ProxyPassReverse / http://localhost:9292/
Step 22. From the gitlab dir execute
[git@gitlab gitlab]$ bundle install --deployment --without development test postgres [git@gitlab gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production
Step 23. If everything went fine you see:
Administrator account created: login.........admin@local.host password......5iveL!fe
Step 24. Get the init script. As we use SCL instead of RVM we need to change some path variables
# cd /etc/init.d/ # wget https://raw.github.com/ldomb/gitlab-recipes/master/gitlab # chmod 755 gitlab # chkconfig gitlab on
Step 25. If you want you can now configure the mail part. Open /etc/mail/sendmail.mc and add or modify the following lines
Add: define(`SMART_HOST', `smtp.example.com')dnl Comment dnl EXPOSED_USER(`root')dnl
Step 26. Restart sendmail
Step 27. forward all email to a centrail mail address
# echo adminlogs@example.com > /root/.forward # chown root /root/.forward # chmod 600 /root/.forward # echo adminlogs@example.com > /home/git/.forward # chown git /home/git/.forward # chmod 600 /home/git/.forward
Step 28. Your done. Start up your server
# service gitlab start