{"id":616,"date":"2013-09-13T20:19:27","date_gmt":"2013-09-14T00:19:27","guid":{"rendered":"http:\/\/blog.domb.net\/?p=616"},"modified":"2014-05-20T15:30:51","modified_gmt":"2014-05-20T19:30:51","slug":"gitlab-6-0-installation-instructions-for-rhel-6-4-and-centos-6-4","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=616","title":{"rendered":"Gitlab 6.0 (6.x) installation instructions with SCL for Rhel 6.4 and Centos 6.4"},"content":{"rendered":"<p>Step 1a. If you have a rhel subscription subscribe to the base, optional and redhat software collection beta channel. You will also need the official nginx repository (http:\/\/wiki.nginx.org\/Install#Official_Red_Hat.2FCentOS_packages).<\/p>\n<p>Step 1. If your on Centos add the SCL repo to your Rhel\/Centos installation and bring in the official nginx repository (http:\/\/wiki.nginx.org\/Install#Official_Red_Hat.2FCentOS_packages ).<\/p>\n<pre class=\"brush:plain\"># yum install -y centos-release-SCL\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\"># yum -y groupinstall 'Development Tools'\r\n\r\n### 'Additional Development'\r\n# yum -y install vim-enhanced 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<\/pre>\n<p>Step 2. As rhel\/centos still did not update the git version 1.7.1-3.el6_4.1 and we need at least 1.7.10 we also need to add the rpm forge package.<\/p>\n<pre class=\"brush:plain\"># yum localinstall -y http:\/\/packages.sw.be\/rpmforge-release\/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm<\/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\"># yum localinstall -y http:\/\/dl.fedoraproject.org\/pub\/epel\/6\/x86_64\/epel-release-6-8.noarch.rpm<\/pre>\n<p>Step 4. Lets install ruby193 and git httpd mysql-server and start all the servies<\/p>\n<pre class=\"brush:plain\"># yum install -y ruby193 ruby193-ruby-devel ruby193-libyaml ruby193-libyaml-devel git redis nginx python-docutils mysql-server\r\n# service mysqld start \r\n# service redis start \r\n# service nginx start \r\n# chkconfig mysqld on\r\n# chkconfig redis on\r\n# chkconfig nginx on<\/pre>\n<p>Step 5. Add the user git and set the git globals<\/p>\n<pre class=\"brush:plain\"># adduser -r -s \/bin\/bash -c 'Gitlab user' -m -d \/home\/git git\r\n# chmod o+x \/home\/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[git@gitlab ~]$ git config --global core.autocrlf input<\/pre>\n<p>Step 6. su to the git user to clone the git repos<\/p>\n<pre class=\"brush:plain\"># 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<\/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\"># .bashrc\r\n# Get the aliases and functions\r\nif [ -f ~\/.bashrc ]; then\r\n        . ~\/.bashrc\r\nfi\r\n\r\nsource \/opt\/rh\/ruby193\/enable<\/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\">[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]<\/pre>\n<p>Step 10. As git cd into the git-shell dir and checkout version 1.7.1<\/p>\n<pre class=\"brush:plain\">[git@gitlab ~]$ cd gitlab-shell\/\r\n[git@gitlab gitlab-shell]$ git checkout v1.7.1\r\nNote: checking out 'v1.7.1'.\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 2c237b7... Fix tests and version up to 1.7.1\r\n[git@gitlab gitlab-shell]$<\/pre>\n<p>Step 11. Copy the file config.yml.example to config.yml in the git-shell directory<br \/>\nStep 12. Install gitshell<\/p>\n<pre class=\"brush:plain\">git@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<\/pre>\n<p>Step 13. IMPORTANT. Do this still as the git user! checkout gitlab 6<\/p>\n<pre class=\"brush:plain\">[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\r\nIn the community edition\r\n[git@gitlab gitlab]$ git checkout 6-0-stable \r\n\r\nBranch 6-0-stable set up to track remote branch 6-0-stable from origin.\r\nSwitched to a new branch '6-0-stable' or master<\/pre>\n<p>Step 14. Lets configure Gitlab and install the gems.<\/p>\n<pre class=\"brush:plain\">[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 json\r\n1 gem installed\r\nInstalling ri documentation for json-1.8.0...\r\nInstalling RDoc documentation for json-1.8.0...\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...<\/pre>\n<p>Step 15. Configure Gitlab<br \/>\nCopy the example GitLab config and edit the necessary fields.<\/p>\n<pre class=\"brush:plain\">[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<\/pre>\n<p>Step 16. Copy the \/home\/git\/gitlab\/config\/unicorn.rb.example to \/home\/git\/gitlab\/config\/unicorn.rb and configure it. Uncomment lines<\/p>\n<pre class=\"brush:plain\">72    old_pid = \"#{server.config[:pid]}.oldbin\"\r\n 73    if old_pid != server.pid\r\n 74      begin\r\n 75        sig = (worker.nr + 1) &gt;= server.worker_processes ? :QUIT : :TTOU\r\n 76        Process.kill(sig, File.read(old_pid).to_i)\r\n 77      rescue Errno::ENOENT, Errno::ESRCH\r\n 78      end\r\n 79    end<\/pre>\n<p>Step 17. Confugre Mysql and change the user and password in the database.yml file<\/p>\n<pre class=\"brush:plain\">production:\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<\/pre>\n<p>Step 18. Create a Mysql User<\/p>\n<pre class=\"brush:plain\">[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';<\/pre>\n<p>Step 19. Check if you can login as the gitlab user<\/p>\n<pre class=\"brush:plain\">[git@gitlab gitlab]$ mysql -u gitlab -p -D gitlabhq_production<\/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\"># \/usr\/bin\/mysql_secure_installation<\/pre>\n<p>Step 21. Add this as your nginx config in \/etc\/nginx\/conf.d\/gitlab.conf<\/p>\n<pre class=\"brush:plain\"> \r\n\r\nupstream gitlab {\r\n  server unix:\/home\/git\/gitlab\/tmp\/sockets\/gitlab.socket;\r\n}\r\n\r\nserver {\r\n  listen *:80 default_server;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea\r\n  server_name gitlab.local.domb.com;     # e.g., server_name source.example.com;\r\n  server_tokens off;     # don't show the version number, a security best practice\r\n  root \/home\/git\/gitlab\/public;\r\n\r\n  # individual nginx logs for this gitlab vhost\r\n  access_log  \/var\/log\/nginx\/gitlab_access.log;\r\n  error_log   \/var\/log\/nginx\/gitlab_error.log;\r\n\r\n  location \/ {\r\n    # serve static files from defined root folder;.\r\n    # @gitlab is a named location for the upstream fallback, see below\r\n    try_files $uri $uri\/index.html $uri.html @gitlab;\r\n  }\r\n\r\n  # if a file, which is not found in the root folder is requested,\r\n  # then the proxy pass the request to the upsteam (gitlab unicorn)\r\n  location @gitlab {\r\n    proxy_read_timeout 300; # https:\/\/github.com\/gitlabhq\/gitlabhq\/issues\/694\r\n    proxy_connect_timeout 300; # https:\/\/github.com\/gitlabhq\/gitlabhq\/issues\/694\r\n    proxy_redirect     off;\r\n\r\n    proxy_set_header   X-Forwarded-Proto $scheme;\r\n    proxy_set_header   Host              $http_host;\r\n    proxy_set_header   X-Real-IP         $remote_addr;\r\n\r\n    proxy_pass http:\/\/gitlab;\r\n  }\r\n}<\/pre>\n<p>Step 22. From the gitlab dir execute if installing with mysql support<\/p>\n<pre class=\"brush:plain\">[git@gitlab gitlab]$ bundle install --deployment --without development test postgres\r\n[git@gitlab gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production<\/pre>\n<p>Step 23. If everything went fine you see:<\/p>\n<pre class=\"brush:plain\">Administrator account created:\r\nlogin.........admin@local.host\r\npassword......5iveL!fe<\/pre>\n<p>Step 24. As root Get the init script.<\/p>\n<pre class=\"brush:plain\"># cp \/home\/git\/gitlab\/lib\/support\/init.d\/gitlab \/etc\/init.d\/gitlab\r\n# chmod +x \/etc\/init.d\/gitlab<\/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\">Add:\r\ndefine(`SMART_HOST', `smtp.example.com')dnl\r\nComment\r\ndnl EXPOSED_USER(`root')dnl<\/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\"># 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<\/pre>\n<p>Step 28. Your done. Start up your server<\/p>\n<pre class=\"brush:plain\"># service gitlab start<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Step 1a. If you have a rhel subscription subscribe to the base, optional and redhat software collection beta channel. You will also need the official nginx repository (http:\/\/wiki.nginx.org\/Install#Official_Red_Hat.2FCentOS_packages). Step 1. If your on Centos add the SCL repo to your Rhel\/Centos installation and bring in the official nginx repository (http:\/\/wiki.nginx.org\/Install#Official_Red_Hat.2FCentOS_packages ). # yum install -y&#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":[],"class_list":["post-616","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/616","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=616"}],"version-history":[{"count":13,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/616\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/616\/revisions\/679"}],"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=616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}