{"id":513,"date":"2013-06-22T16:00:18","date_gmt":"2013-06-22T20:00:18","guid":{"rendered":"http:\/\/blog.domb.net\/?p=513"},"modified":"2013-09-14T19:05:58","modified_gmt":"2013-09-14T23:05:58","slug":"gitlab-on-rhel6-4-with-scl-software-collection","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=513","title":{"rendered":"Gitlab 5.2 on RHEL\/Centos 6.4 with SCL \/ Software Collection outdated"},"content":{"rendered":"<p>Redhat release software collection\u00a0January this year. It&#8217;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 &#8220;https:\/\/github.com\/gitlabhq\/gitlab-recipes&#8221; and shows you howto make gitlab work with SCL instead of RVM.<\/p>\n<p>Step 1. Add the SCL repo to your Rhel\/Centos installation<\/p>\n<p><a href=\"http:\/\/people.redhat.com\/bkabrda\/scl_ruby193.repo\">http:\/\/people.redhat.com\/bkabrda\/scl_ruby193.repo<\/a><\/p>\n<pre class=\"brush:plain\">[scl_ruby193]\r\nname=Ruby 1.9.3 Dynamic Software Collection\r\nbaseurl=http:\/\/people.redhat.com\/bkabrda\/ruby193-rhel-6\/\r\nfailovermethod=priority\r\nenabled=1\r\ngpgcheck=0\r\n<\/pre>\n<p>Make sure you are also subscribed to the rhel6-server optional channel. Then install the Development tools<\/p>\n<pre class=\"brush:plain\">\r\n# yum -y groupinstall 'Development Tools'\r\n\r\n### 'Additional Development'\r\n# yum -y install vim-enhanced httpd readline readline-devel ncurses-devel gdbm-devel glibc-devel \\\r\n               tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc \\\r\n               sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel \\\r\n               libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel \\\r\n               system-config-firewall-tui python-devel redis sudo mysql-server wget \\\r\n               mysql-devel crontabs logwatch logrotate sendmail-cf qtwebkit qtwebkit-devel \\\r\n               perl-Time-HiRes libicu-devel libxml2-devel libxslt-devel mysql-devel\r\n<\/pre>\n<p>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<\/p>\n<pre class=\"brush:plain\">\r\n# yum localinstall -y http:\/\/packages.sw.be\/rpmforge-release\/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm\r\n<\/pre>\n<p>Enable the rpmforge <strong>extras<\/strong><\/p>\n<p>Step 3. Gitlab also needs redis which is available on epel. <\/p>\n<pre class=\"brush:plain\">\r\n# yum localinstall -y http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm\r\n<\/pre>\n<p>Step 4. Lets install ruby193 and git httpd mysql-server and start all the servies<\/p>\n<pre class=\"brush:plain\">\r\n# yum install -y ruby193 ruby193-ruby-devel git redis httpd mysql-server\r\n# service mysqld start \r\n# service redis start \r\n# service httpd start \r\n# chkconfig mysqld on\r\n# chkconfig redis on\r\n# chkconfig httpd on\r\n<\/pre>\n<p>Step 5. Add the user git and set the git globals<\/p>\n<pre class=\"brush:plain\">\r\n# adduser -r -s \/bin\/bash -c 'Gitlab user' -m -d \/home\/git git\r\n# su - git\r\n[git@gitlab ~]$ git config --global user.name \"GitLab\"\r\n[git@gitlab ~]$ git config --global user.email \"gitlab@localhost\"\r\n<\/pre>\n<p>Step 6. su to the git user to clone the git repos<\/p>\n<pre class=\"brush:plain\">\r\n# su - git\r\n[git@gitlab ~]$ git clone https:\/\/github.com\/gitlabhq\/gitlab-shell.git\r\n[git@gitlab ~]$ git clone https:\/\/github.com\/gitlabhq\/gitlabhq.git gitlab\r\n<\/pre>\n<p>Step 7. Extend your .bashrc to have the following content which will load our scl environment for us when we login<\/p>\n<pre class=\"brush:plain\">\r\n# .bashrc\r\n# Get the aliases and functions\r\nif [ -f ~\/.bashrc ]; then\r\n        . ~\/.bashrc\r\nfi\r\n\r\nLD_LIBRARY_PATH=\/opt\/rh\/ruby193\/root\/usr\/lib64:\r\n\r\nPATH=\/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\r\nexport PATH\r\nexport LD_LIBRARY_PATH\r\n<\/pre>\n<p>Step 8. Make sure the paths are right. You can test this by executing env. <\/p>\n<p>Step 9. Logout and login again as user gitlab. If everything went fine you should be able to do this<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab ~]$ which ruby\r\n\/opt\/rh\/ruby193\/root\/usr\/bin\/ruby\r\n[git@gitlab ~]$ ruby --version\r\nruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]\r\n<\/pre>\n<p>Step 10. As git cd into the git-shell dir and checkout version 1.4<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab ~]$ cd gitlab-shell\/\r\n[git@gitlab gitlab-shell]$ git checkout v1.4.0\r\nNote: checking out 'v1.4.0'.\r\n\r\nYou are in 'detached HEAD' state. You can look around, make experimental\r\nchanges and commit them, and you can discard any commits you make in this\r\nstate without impacting any branches by performing another checkout.\r\n\r\nIf you want to create a new branch to retain commits you create, you may\r\ndo so (now or later) by using -b with the checkout command again. Example:\r\n\r\n  git checkout -b new_branch_name\r\n\r\nHEAD is now at 8343298... Fix tests and version up to 1.4.0\r\n[git@gitlab gitlab-shell]$ \r\n<\/pre>\n<p>Step 11. Copy the file config.yml.example to config.yml and and replace the hostname localhost with your hostname<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab-shell]$ sed -i 's\/localhost\/gitlab.local.domb.com\/g' config.yml\r\n<\/pre>\n<p>Step 12. Install gitshell<\/p>\n<pre class=\"brush:plain\">\r\ngit@gitlab gitlab-shell]$ .\/bin\/install\r\nmkdir -p \/home\/git\/repositories: true\r\nmkdir -p \/home\/git\/.ssh: true\r\nchmod 700 \/home\/git\/.ssh: true\r\ntouch \/home\/git\/.ssh\/authorized_keys: true\r\nchmod 600 \/home\/git\/.ssh\/authorized_keys: true\r\nchmod -R ug+rwX,o-rwx \/home\/git\/repositories: true\r\nfind \/home\/git\/repositories -type d -print0 | xargs -0 chmod g+s: true\r\n<\/pre>\n<p>Step 13. IMPORTANT. Do this still as the git user! checkout gitlab 5.2<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab ~]$ cd gitlab\r\n[git@gitlab gitlab]$ ls\r\napp              CONTRIBUTING.md  Gemfile.lock  MAINTENANCE.md  script\r\nCapfile.example  db               Guardfile     Procfile        spec\r\nCHANGELOG        doc              lib           public          tmp\r\nconfig           features         LICENSE       Rakefile        vendor\r\nconfig.ru        Gemfile          log           README.md       VERSION\r\n[git@gitlab gitlab]$ git checkout 5-2-stable\r\nBranch 5-2-stable set up to track remote branch 5-2-stable from origin.\r\nSwitched to a new branch '5-2-stable'\r\n<\/pre>\n<p>Step 14. Lets configure Gitlab and install the gems<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab]$  gem install bundler\r\nFetching: bundler-1.3.5.gem (100%)\r\nSuccessfully installed bundler-1.3.5\r\n1 gem installed\r\nInstalling ri documentation for bundler-1.3.5...\r\nInstalling RDoc documentation for bundler-1.3.5.\r\n\r\n[git@gitlab gitlab]$ gem install charlock_holmes --version '0.6.9.4'\r\nBuilding native extensions.  This could take a while...\r\n....\r\n......................\r\n.\r\nSuccessfully installed charlock_holmes-0.6.9.4\r\n1 gem installed\r\nInstalling ri documentation for charlock_holmes-0.6.9.4...\r\nInstalling RDoc documentation for charlock_holmes-0.6.9.4...\r\n<\/pre>\n<p>Step 15. Configure Gitlab<br \/>\nCopy the example GitLab config and edit the necessary fields.<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab]$ cp \/home\/git\/gitlab\/config\/gitlab.yml{.example,}\r\n[git@gitlab gitlab]$ sed -i 's\/localhost\/gitlab.local.domb.com\/g' \/home\/git\/gitlab\/config\/gitlab.yml\r\n[git@gitlab gitlab]$ chown -R git \/home\/git\/gitlab\/log\/\r\n[git@gitlab gitlab]$ chown -R git \/home\/git\/gitlab\/tmp\/\r\n[git@gitlab gitlab]$ chmod -R u+rwX \/home\/git\/gitlab\/log\/\r\n[git@gitlab gitlab]$ chmod -R u+rwX  \/home\/git\/gitlab\/tmp\/\r\n[git@gitlab gitlab]$ mkdir \/home\/git\/gitlab-satellites\r\n[git@gitlab gitlab]$ mkdir \/home\/git\/gitlab\/tmp\/pids\/\r\n[git@gitlab gitlab]$ mkdir \/home\/git\/gitlab\/tmp\/sockets\/\r\n[git@gitlab gitlab]$ chmod -R u+rwX \/home\/git\/gitlab\/tmp\/pids\/\r\n[git@gitlab gitlab]$ chmod -R u+rwX \/home\/git\/gitlab\/tmp\/sockets\/\r\n[git@gitlab gitlab]$ mkdir \/home\/git\/gitlab\/public\/uploads\r\n[git@gitlab gitlab]$ chmod -R u+rwX \/home\/git\/gitlab\/public\/uploads\r\n<\/pre>\n<p>Step 16. Copy the puma.rb config and configure it. Change the bind parameter so that it reads: bind &#8216;tcp:\/\/127.0.0.1:9292&#8217;<\/p>\n<p>Step 17. Confugre Mysql and change the user and password in the database.yml file<\/p>\n<pre class=\"brush:plain\">\r\nproduction:\r\n  adapter: mysql2\r\n  encoding: utf8\r\n  reconnect: false\r\n  database: gitlabhq_production\r\n  pool: 5\r\n  username: gitlab\r\n  password: \"iloveopensource\"\r\n  # host: localhost\r\n  # socket: \/tmp\/mysql.sock\r\n<\/pre>\n<p>Step 18. Create a Mysql User<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab]$ mysql -u root\r\n# Create a user for GitLab. (change supersecret to a real password)\r\nCREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'iloveopensource';\r\n# Create the GitLab production database\r\nCREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;\r\n# Grant the GitLab user necessary permissions on the table.\r\nGRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';\r\n<\/pre>\n<p>Step 19. Check if you can login as the gitlab user<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab]$ mysql -u gitlab -p -D gitlabhq_production\r\n<\/pre>\n<p>Step 20. Secure MySQL by entering a root password and say &#8220;Yes&#8221; to all questions with the next command<\/p>\n<pre class=\"brush:plain\">\r\n# \/usr\/bin\/mysql_secure_installation\r\n<\/pre>\n<p>Step 21. Add this as your apache config in \/etc\/httpd\/conf.d\/gitlab.conf<\/p>\n<pre class=\"brush:plain\">\r\n      ServerName gitlab.local.domb.com\r\n      ProxyRequests Off\r\n        \r\n           Order deny,allow\r\n           Allow from all\r\n        \r\n        ProxyPreserveHost On\r\n        ProxyPass \/ http:\/\/localhost:9292\/\r\n        ProxyPassReverse \/ http:\/\/localhost:9292\/\r\n<\/pre>\n<p>Step 22. From the gitlab dir execute<\/p>\n<pre class=\"brush:plain\">\r\n[git@gitlab gitlab]$ bundle install --deployment --without development test postgres\r\n[git@gitlab gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production\r\n<\/pre>\n<p>Step 23. If everything went fine you see:<\/p>\n<pre class=\"brush:plain\">\r\nAdministrator account created:\r\nlogin.........admin@local.host\r\npassword......5iveL!fe\r\n<\/pre>\n<p>Step 24. Get the init script. As we use SCL instead of RVM we need to change some path variables<\/p>\n<pre class=\"brush:plain\">\r\n# cd \/etc\/init.d\/\r\n# wget https:\/\/raw.github.com\/ldomb\/gitlab-recipes\/master\/gitlab\r\n# chmod 755 gitlab\r\n# chkconfig gitlab on\r\n<\/pre>\n<p>Step 25. If you want you can now configure the mail part. Open \/etc\/mail\/sendmail.mc and add or modify the following lines<\/p>\n<pre class=\"brush:plain\">\r\nAdd:\r\ndefine(`SMART_HOST', `smtp.example.com')dnl\r\nComment\r\ndnl EXPOSED_USER(`root')dnl\r\n<\/pre>\n<p>Step 26. Restart sendmail<\/p>\n<p>Step 27. forward all email to a centrail mail address<\/p>\n<pre class=\"brush:plain\">\r\n# echo adminlogs@example.com &gt; \/root\/.forward\r\n# chown root \/root\/.forward\r\n# chmod 600 \/root\/.forward\r\n# echo adminlogs@example.com &gt; \/home\/git\/.forward\r\n# chown git \/home\/git\/.forward\r\n# chmod 600 \/home\/git\/.forward\r\n<\/pre>\n<p>Step 28. Your done. Start up your server<\/p>\n<pre class=\"brush:plain\">\r\n# service gitlab start\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Redhat release software collection\u00a0January this year. It&#8217;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 &#8220;https:\/\/github.com\/gitlabhq\/gitlab-recipes&#8221; and shows you howto&#8230;<\/p>\n","protected":false},"author":2,"featured_media":565,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[3],"tags":[16,17,18],"class_list":["post-513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-gitlab","tag-rhel-6-4","tag-scl"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=513"}],"version-history":[{"count":61,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions"}],"predecessor-version":[{"id":623,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/513\/revisions\/623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/565"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}