Home » Centos/RHEL » Install and configure GitLab on Ubuntu.

Install and configure GitLab on Ubuntu.

GitLab is an extraordinarily powerful open source code cooperation platform, git repository manager GitLab provides git repository management, code reviews, issue tracking, Gitlab easily integrate with LDAP and Active Directory server. It’s fully supported with mysql and postgreysql database server.

Install GitLab on ubuntu

root@git:~# apt-get install -y libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev build-essential
Processing triggers for libc-bin …
ldconfig deferred processing now taking place
root@git:~# cd /tmp/

install git 2.0.0

root@git:/tmp# curl -L –progress https://www.kernel.org/pub/software/scm/git/git-2.0.0.tar.gz | tar xz
######################################################################## 100.0%
root@git:/tmp#
root@git:~# cd git-2.0.0/
root@git:~# make prefix=/usr/local all
root@git:~# Install into /usr/local/bin
root@git:~# sudo make prefix=/usr/local install

Note :- While editing config/gitlab.yml (Step 5), change the git -> bin_path to /usr/local/bin/git
Install and configure postfix as public internet site

root@git:~#apt-get install -y postfix

install ruby 2.1.2

root@git:~# mkdir /tmp/ruby && cd /tmp/ruby
root@git:/tmp/ruby# curl -L –progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz | tar xz
######################################################################## 100.0%
######################################################################## 100.0%root@git:/tmp/ruby#
root@git:~# cd ruby-2.1.2
root@git:/tmp/ruby/ruby-2.1.2#./configure –disable-install-rdoc
root@git:/tmp/ruby/ruby-2.1.2##make
root@git:/tmp/ruby/ruby-2.1.2##sudo make install

Install the Bundler Gem:

root@git:/tmp/#sudo gem install bundler –no-ri –no-rdoc

3. System Users
Create a git user for GitLab:

root@git:/tmp/#sudo adduser –disabled-login –gecos ‘GitLab’ git
Adding user `git’ …
Adding new group `git’ (1001) …
Adding new user `git’ (1001) with group `git’ …
Creating home directory `/home/git’ …
Copying files from `/etc/skel’ …

install mysql
# Install the database packages

root@git:/tmp/#sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

Verify you have MySQL version 5.5.14

mysql –version

Create a user and database for GitLab

mysql> CREATE USER ‘git’@’localhost’ IDENTIFIED BY ‘$password’;
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
mysql> SET storage_engine=INNODB;
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO ‘git’@’localhost’;

# verify connection with new database with the new user

root@git:/tmp/#sudo -u git -H mysql -u git -p -D gitlabhq_production

# You are done installing the database and can go back to the rest of the installation.
5. Redis

root@git:/tmp/#sudo apt-get install redis-server

# Configure redis to use sockets

root@git:/tmp/#sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig

Disable Redis listening on TCP by setting ‘port’ to 0

root@git:/tmp/#sed ‘s/^port .*/port 0/’ /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf

Enable Redis socket for default Debian / Ubuntu path

root@git:/tmp/#echo ‘unixsocket /var/run/redis/redis.sock’ | sudo tee -a /etc/redis/redis.conf

Restart redis to Activate the changes to redis.conf

root@git:/tmp/#sudo service redis-server restart

Add git to the redis group

root@git:/tmp/#sudo usermod -aG redis git

6. GitLab Installation and configuration
We are going to install GitLab into home directory of the user “git”

root@git:/tmp/#cd /home/git
root@git:/tmp/#sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-3-stable gitlab
root@git:/tmp/#cd /home/git/gitlab

Copy the example GitLab config

root@git:/tmp/#sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

# Update GitLab config file, according instructions at top of file

root@git:/tmp/#sudo -u git -H editor config/gitlab.yml

Make sure GitLab can write to the log/ and tmp/ directories

root@git:/tmp/#sudo chown -R git log/
root@git:/tmp/#sudo chown -R git tmp/
root@git:/tmp/#sudo chmod -R u+rwX log/
root@git:/tmp/#sudo chmod -R u+rwX tmp/

Create directory for satellites

root@git:/tmp/#sudo -u git -H mkdir /home/git/gitlab-satellites
root@git:/tmp/#sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites

Make sure GitLab is able write to the tmp/pids/ and tmp/sockets/ directories

root@git:/tmp/#sudo chmod -R u+rwX tmp/pids/
root@git:/tmp/#sudo chmod -R u+rwX tmp/sockets/

Make sure GitLab is able write to the public/uploads/ directory

root@git:/tmp/#udo chmod -R u+rwX public/uploads

Copy the example Unicorn config

root@git:/tmp/#sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb

verify available cores on the server

root@git:/tmp/#nproc
2
root@git:/tmp/#sudo -u git -H editor config/unicorn.rb

# Copy the example Rack attack config

root@git:/tmp/#sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

Configure Git global settings for git user, useful when editing via web
Replace the user.email with original mail id

root@git:/tmp/#sudo -u git -H git config –global user.name “GitLab”
root@git:/tmp/#sudo -u git -H git config –global user.email “example@example.com”
root@git:/tmp/#sudo -u git -H git config –global core.autocrlf input

Setup and configure Redis connection settings

root@git:/tmp/#sudo -u git -H cp config/resque.yml.example config/resque.yml

if you need to Change the Redis socket path if you are not using the default Debian / Ubuntu configuration

root@git:/tmp/#sudo -u git -H editor config/resque.yml

Important Note: Make sure to cofigure both gitlab.yml and unicorn.rb to according your setup.
Configure GitLab DB Settings
# PostgreSQL only:

root@git:/tmp/#sudo -u git cp config/database.yml.postgresql config/database.yml

# MySQL only:

root@git:/tmp/#sudo -u git cp config/database.yml.mysql config/database.yml
root@git:/tmp/#sudo -u git -H editor config/database.yml

dabaname
database user
database user password

root@git:/tmp/#sudo -u git -H chmod o-rwx config/database.yml

install gems For PostgreSQL database

root@git:/tmp/#sudo -u git -H bundle install –deployment –without development test mysql aws

install gems for Mysql database

root@git:/tmp/#sudo -u git -H bundle install –deployment –without development test postgres aws

Install GitLab shell

root@git:/tmp/#sudo -u git -H bundle exec rake gitlab:shell:install[v2.0.1] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production

If you want modify gitlab-shell config as follows:

root@git:/tmp/#sudo -u git -H editor /home/git/gitlab-shell/config.yml

Initialize Database and Activate Advanced Features

root@git:/tmp/#sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
Administrator account created:
login………root
password……#{password}

To change the password perform the following command.

root@git:/tmp/#sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=newpassword

Configure GitLab init script

root@git:/tmp/#sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
root@git:/tmp/#sudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlab

Note : If you installed GitLab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab. Do not edit /etc/init.d/gitlab as it will be changed on upgrade.
Setup GitLab start on boot time:

root@git:/tmp/#sudo update-rc.d gitlab defaults 21

To Setup Logrotate

root@git:/tmp/#sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

Verify if GitLab and its environment are configured properly or not:

root@git:/tmp/#sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

Compile Assets

root@git:/tmp/#sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

Start Your GitLab server

root@git:/tmp/#sudo service gitlab start

or

root@git:/tmp/#sudo /etc/init.d/gitlab restart

Finally Install nginx to access the gitlab through browser

root@git:/tmp/#apt-get install nginx

Site Configuration according GitLab

root@git:/tmp/#sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
root@git:/tmp/#sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

Edit the config file and change default domain with your FQDN hostname or domain name:

root@git:/tmp/#sudo editor /etc/nginx/sites-available/gitlab

Finally restart the nginx

root@git:/tmp/#service nginx restart

or

root@git:/tmp/#/etc/init.d/nginx restart

Verify the application status

root@git:/tmp/#sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

Finally access GitLab by using http://server-IP-or-hostname/ url.

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry from last 7 years.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud