Monday 22 August 2016

Install GitLab 5.3 on Mac OS X server 10.8.4

Below are the steps to install GitLab 5.3 on a fresh Mac OS X server 10.8.4 (server version 2.2)
1) Install a fresh mac ox x 10.8.4
2) Create user group “git” and a user “git” in this group
3) Enable remote login for “git” user
4) Install Xcode 4.6.2
5) Install command line tools in Xcode.
6) Install Home brew

1
2
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew doctor
7) Now install some prerequisites
1
2
3
4
5
6
$ brew install icu4c # Necessary for the charlock_holmes gem install later
$ brew install git # Install git 1.8 or greater...
$ brew install redis
$ mkdir ~/Library/LaunchAgents # create launchAgents dir (it does not exist in fresh system)
$ ln -sfv /usr/local/opt/redis/homebrew.mxcl.redis.plist ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Make sure you have python 2.5+ (gitlab don’t support python 3.x)
1
2
$ python --version # Confirm python 2.5+
$ sudo ln -s /usr/bin/python /usr/bin/python2 #GitLab looks for python2
Some more dependices
1
2
$ sudo easy_install pip
$ sudo pip install pygments
8) Install MySql server download form here – http://dev.mysql.com/downloads/mysql
9) Setup database
Start MySql server from system preferences and change root password
1
$ /usr/local/mysql/bin/mysqladmin -u root password NEW_PASSWORD_HERE
make sure mysql is in your PATH -
1
$ export PATH=/usr/local/mysql/bin:$PATH
Now login in mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ mysql -u root -p
 
#Create a new user for our gitlab setup 'gitlab'
 
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'PASSWORD_HERE';
 
#Create database
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
 
# Grant the GitLab user necessary permissions on the table.
mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
 
# Quit the database session
mysql> \q
 
# Try connecting to the new database with the new user
sudo -u git -H mysql -u gitlab -p -D gitlabhq_production
10) Install Ruby 
1
2
3
4
5
6
7
8
9
10
11
12
13
$ brew install rbenv
$ brew install ruby-build
 
# Make sure rbenv loads in the git user's shell
$ echo 'export PATH="/usr/local/bin:$PATH"' | sudo -u git tee -a /Users/git/.profile
 
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' | sudo -u git tee -a /Users/git/.profile
 
$ sudo -u git cp /Users/git/.profile /Users/git/.bashrc
 
# Install ruby 1.9.3 for the git user
$ sudo -u git -H -i rbenv install 1.9.3-p392
$ sudo -u git -H -i 'rbenv global 1.9.3-p392'
Install ruby 1.9.3 for your user too and set rbenv to use it. This is for installing global gems later.
1
2
$ rbenv install 1.9.3-p392
$ rbenv global 1.9.3-p392
11) Install rails 
1
$ sudo gem install rails
12) Install Gitlab Shell
1
2
3
4
5
$ cd /Users/git
$ sudo -u git git clone https://github.com/gitlabhq/gitlab-shell.git
$ cd gitlab-shell
$ sudo -u git git checkout v1.4.0
$ sudo -u git cp config.yml.example config.yml
Now open config.yml file and edit it
a) Change gitlab url to reflect your URL
b) Change all instances of “/home” to “/Users” (we are on mac)
c) Change redis-cli path to home-brew’s cli path – “/usr/local/bin/redis-cli”
13) Install GitLab -
Download Gitlab -
1
2
3
4
$ cd /Users/git
$ sudo -u git git clone https://github.com/gitlabhq/gitlabhq.git gitlab
$ cd gitlab
$ sudo -u git git checkout 5-3-stable
Configuring GitLab
1
2
# Copy the example GitLab config
$ sudo -u git cp config/gitlab.yml.example config/gitlab.yml
Open gitlab.yml file and change “/home” to “/Users” and make sure to change “gitlab.example.com” to the fully-qualified domain name of your
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Make sure GitLab can write to the log/ and tmp/ directories
$ sudo chown -R git log/
$ sudo chown -R git tmp/
$ sudo chmod -R u+rwX  log/
$ sudo chmod -R u+rwX  tmp/
 
# Create directories for repositories make sure GitLab can write to them
$ sudo -u git mkdir /Users/git/repositories
$ sudo chmod -R u+rwX  /Users/git/repositories/
 
# Create directory for satellites
$ sudo -u git mkdir /Users/git/gitlab-satellites
 
# Create directories for sockets/pids and make sure GitLab can write to them
$ sudo -u git mkdir tmp/pids/
$ sudo -u git mkdir tmp/sockets/
 
$ sudo chmod -R u+rwX  tmp/pids/
$ sudo chmod -R u+rwX  tmp/sockets/
 
# Create public/uploads directory otherwise backup will fail
$ sudo -u git mkdir public/uploads
$ sudo chmod -R u+rwX  public/uploads
 
# Copy the example Puma config
$ sudo -u git cp config/puma.rb.example config/puma.rb
Open puma.rb file and change “/home” to “/Users”
1
2
3
# Configure Git global settings for git user, useful when editing via web
$ sudo -u git -H git config --global user.name "GitLab"
$ sudo -u git -H git config --global user.email "gitlab@gitlab.example.com"
Gitlab Mysql Config.
1
$ sudo -u git cp config/database.yml.mysql config/database.yml
Edit production section in this database.yml file with user “gitlab” and its password
Install Gems
1
2
3
$ sudo gem install charlock_holmes --version '0.6.9.4'
$ sudo -u git -H bash -l -c 'gem install bundler'
$ sudo -u git -H bash -l -c 'bundle install --deployment --without development test postgres'
Initialising Database
1
$ sudo -u git -H bash -l -c 'bundle exec rake gitlab:setup RAILS_ENV=production'
Got error in above -
rake aborted!
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (dlopen(/Users/    git/gitlab/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library     not loaded: libmysqlclient.18.dylib
So installing “activerecord-mysql2-adapter”
1
$ gem install activerecord-mysql2-adapter
This also did not resolved the issue so I searched again on SO and found this -
1
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
And run
1
$ sudo -u git -H bash -l -c 'bundle exec rake gitlab:setup RAILS_ENV=production'
Worked this time
Check GitLab installation
check environment configuration
1
sudo -u git -H bash -l -c 'bundle exec rake gitlab:env:info RAILS_ENV=production'
Do a through check. Make sure everything is green.
1
sudo -u git -H bash -l -c 'bundle exec rake gitlab:check RAILS_ENV=production'
If you are getting some error please fix that first.
14) Lets take it up
1
$ rails s -e production -p 8080
15) Now open http://localhost:8080 in your browser and login with these below details
login………admin@local.host
password……5iveL!fe
I hope you find this above guide useful and it will save some of your time struggling missing gems, libraries, permissions etc. In next tutorial we’ll set it up on Nginx server.

No comments:

Post a Comment