How to install GitLab 6.6.5 on debian/Ubuntu with nginx subdir

How to install GitLab 6.6.5 on debian/Ubuntu with nginx subdir

How to install GitLab 6.6.5 on debian/Ubuntu with nginx subdir

How to install GitLab 6.6.5 on debian/Ubuntu with nginx subdir への13件のコメント

How to install GitLab 6.6.5 on debian/Ubuntu with nginx subdir

I introduce you ,how to install GitLab on debian(wheezy) or Ubuntu(12.04 Server or other). Hosting GitLab App in a subdirectory of nginx with using passenger.

I examine this on debian wheezy 7.4 and Ubuntu Server 12.04.4, This way might be a possibility on other debian’s distribution.

if my introduction is wrong, please post a comment!!

The first half of this article is instration of Rails environment ,because of GitLab is made by Ruby on Rails.the latter half is instration of GitLab and hosting GitLab on nginx subdirectory with fusion passenger.

Precondition

using nginx as a Web server

Hosting Rails app with nginx and passenger

GitLab app deploy subdir of nginx

Hostname of GitLab *** www.myhost.jp

Uri of GitLab *** http://www.myhost.jp/gitlab

create git user ,sudo privileges to the user

[bash]
$ sudo useradd git -md /home/git -s /bin/bash
$ sudo passwd git
$ sudo nano /etc/suders
[/bash]

grant sudo privileges to git
[diff mark=”3″ ]
# User privilege specification
root ALL=(ALL:ALL) ALL
+ git ALL=(ALL:ALL) ALL
[/diff]

Requirements for installing

[bash]
$ su – git

$ sudo apt-get install curl git build-essential libgtk2.0-dev libmysqlclient-dev mysql-server dialog zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl git-core openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils sysv-rc-conf

[/bash]

create .gemrc file

create ~/.gemrc file to prevent rdoc and ri installation.
[bash]
$ nano ~/.gemrc
[/bash]

[diff]
gem: –no-ri –no-rdoc
[/diff]

install Ruby and Rails

minimum requirements for Ruby 1.9.

if the distribution has a ruby package version 1.9 or over.
[bash]
$ sudo apt-get install ruby ruby-dev
$ sudo gem install rails

[/bash]

Ubuntu 12.04
if the distribution has a ruby package version 1.8.
[bash]
$ sudo apt-get install python-software-properties
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.1 ruby2.1-dev

$ sudo gem install rails
[/bash]

REDIS configuration,start service

[bash]
$ sudo service redis-server restart
$ sudo sysv-rc-conf redis-server on
[/bash]

The latter half is to install GitLab and nginx.

Installing Gitlab-shell

[bash]
$ git config –global user.name “GitLab”
$ git config –global user.email “gitlab@localhost”
$ git clone https://github.com/gitlabhq/gitlab-shell.git
$ cd gitlab-shell/
$ git checkout -b 1.8.5 v1.8.5
$ cp config.yml.example config.yml
$ nano config.yml
[/bash]

adjust gitlab_url.

[diff]
– gitlab_url: “http://localhost/” << remove this line + gitlab_url: "http://www.myhost.jp/gitlab/" [/diff] exec installation [bash] $ ./bin/install [/bash]

Instralling GitLab

Check out GitLab sources from GitHub.
(It takes about 20 minites.total download size approximates 70MB)

[bash]

$ cd /home/git
$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab
$ cd gitlab
$ git checkout -b 6.6.5 v6.6.5
$ cp config/gitlab.yml.example config/gitlab.yml
$ nano config/gitlab.yml
[/bash]

Hostname、Relative Url Root

[diff]
– host: localhost
+ host: www.myhost.jp

https: false

# Uncomment and customize the last line to run in a non-root path
# WARNING: We recommend creating a FQDN to host GitLab in a root path instead of this.

# Note that four settings need to be changed for this to work.
# 1) In your application.rb file: config.relative_url_root = “/gitlab”
# 2) In your gitlab.yml file: relative_url_root: /gitlab
# 3) In your unicorn.rb: ENV[‘RAILS_RELATIVE_URL_ROOT’] = “/gitlab”
# 4) In ../gitlab-shell/config.yml: gitlab_url: “http://127.0.0.1/gitlab”
# To update the path, run: sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

#
– # relative_url_root: /gitlab
+ relative_url_root: /gitlab

[/diff]

Relative Url Root

[bash]
$ nano config/application.rb
[/bash]

[diff mark=”2,19″]
– # config.relative_url_root = “/gitlab”
+ config.relative_url_root = “/gitlab”

*
*
*
*
*

end
end
end
end


+ ENV[‘RAILS_RELATIVE_URL_ROOT’] = “/gitlab”

[/diff]

Mysql configuration

adjust user name and password for Production mode.
[bash]
$ cp config/database.yml.mysql config/database.yml
$ nano config/database.yml
[/bash]

[diff]
#
# PRODUCTION
#
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: gitlabhq_production
pool: 10
– username: git
– password: “secure password”
+ username: root
+ password: “xxxxxxxxx”
# host: localhost
# socket: /tmp/mysql.sock
[/diff]

Run bundle install

[bash]
$ bundle install –deployment –without development test postgres
[/bash]

Create Directories

[bash]
$ mkdir /home/git/gitlab/tmp/pids
$ mkdir /home/git/gitlab/public/uploads
[/bash]

Create database

[bash]
$ rake db:create RAILS_ENV=production
$ rake gitlab:setup RAILS_ENV=production

[/bash]

if the creation complete, user name and password are shown.
please put it down.

login………admin@local.host
password……5iveL!fe

Create a service script and configuration

By default, Application server of GitLab is puma. But I use fusion passenger as Application server.
So I create a service script of GitLab(sidekiq)

please download from this site.

[bash]
$ wget http://lovelinux.mydns.jp/wp-content/uploads/2014/03/gitlab.sh

$ sudo cp gitlab.sh /etc/init.d/gitlab
$ sudo chmod 744 /etc/init.d/gitlab
$ sudo sysv-rc-conf gitlab on

$ sudo service gitlab start
[/bash]

Instralling nginx

Compiling nginx for cooperation with passenger.

Installing passenger gem

[bash]
$ sudo gem install passenger
[/bash]

Compiling nginx

[bash]
$ sudo passenger-install-nginx-module
[/bash]

Pass the checking requirements for compilation, a message is shown whether if you continue compile?
please select 1.

[bash]
Please specify a prefix directory [/opt/nginx]:

Nginx with Passenger support was successfully installed.

The Nginx configuration file (/opt/nginx/conf/nginx.conf)
must contain the correct configuration options in order for Phusion Passenger
to function correctly.

This installer has already modified the configuration file for you! The
following configuration snippet was inserted:

http {

passenger_root /var/lib/gems/1.9.1/gems/passenger-4.0.39;
passenger_ruby /usr/bin/ruby1.9.1;

}

After you start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.

[/bash]

permission of /opt/nginx

[bash]
$ sudo chown www-data:www-data /opt/nginx -R
$ sudo chmod 775 /opt/nginx -R
[/bash]

check configration of nginx, start service

checking the configration of nginx with -t option.
If configuration is OK, test with a browser.
By accessing http://localhost in browser,top page of nginx is shown,test is complete.

[bash]
$ sudo /opt/nginx/sbin/nginx -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful

$ sudo /opt/nginx/sbin/nginx
[/bash]

check process id(pid) of nginx master.
[bash]
$ ps aux |grep nginx
[/bash]

kill process of nginx : master process
[bash]
$ sudo kill pid
[/bash]

nginx cooperate with passenger

[bash]
$ sudo nano /opt/nginx/conf/nginx.conf
[/bash]

Add these lines to nginx.conf
Attension!!! line of pid, separate pid and /opt/nginx/logs/nginx.pid with tab char!!
because service script of nginx reads this line ,and judge pid by the tab char.

[diff mark=”2″]
+ user www-data;
+ pid /opt/nginx/logs/nginx.pid;

*
*
*
*

server {
listen 80;
server_name localhost;

*
*
*
*


+ location ~ ^/gitlab {
+ root /home/git/gitlab/public;
+ #passenger_base_uri /gitlab;
+ passenger_app_root /home/git/gitlab;
+ #passenger_document_root /home/git/gitlab/public;
+ passenger_enabled on;
+ rails_env production;
+ access_log /opt/nginx/logs/gitlab.access.log;
+ error_log /opt/nginx/logs/gitlab.error.log;
+ }

*
*
*
*

[/diff]

Service Script of nginx

I create a service script of nginx.

the script can downlaod from here.
Service script of nginx

[diff mark=”14,28″]
#!/bin/sh

### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx

# Include nginx defaults if available
if [ -r /etc/default/nginx ]; then
. /etc/default/nginx
fi

test -x $DAEMON || exit 0

. /lib/init/vars.sh
. /lib/lsb/init-functions

PID=$(awk -F'[ \t;]’ ‘$1 !~ /^#/ && /pid/ {print $2}’ /opt/nginx/conf/nginx.conf)

if [ -z “$PID” ]
then
PID=/run/nginx.pid
fi

# Check if the ULIMIT is set in /etc/default/nginx
if [ -n “$ULIMIT” ]; then
# Set the ulimits
ulimit $ULIMIT
fi

#
# Function that starts the daemon/service
#
do_start()
{

*
*
*
*
*
*

[/diff]

Copy the script and service registration

[bash]

$ sudo mv nginx /etc/init.d/
$ sudo chmod 755 /etc/init.d/nginx
$ sudo chown root:root /etc/init.d/nginx

$ sudo sysv-rc-conf nginx on

[/bash]

if you want start or stop or restart nginx,following commands are available.

[bash]

sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
[/bash]

or

[bash]

sudo service nginx start
[/bash]

modification of nginx(www-data)

to access /home/git/repositories folder ,add nginx user to git group.

[bash]
$ sudo usermod -aG git www-data

[/bash]

Precompile of assets

after precompiling, please restart nginx service.

[bash]
$ cd /home/git/gitlab
$ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

$ sudo service nginx restart
[/bash]

Now, Check the GitLab!!

With a browser,accsess to http://www.myhost.jp/gitlab

Screenshot-GitLab - Chromium

Login to GitLab

login………admin@local.host
password……5iveL!fe

Create a Project(repository)

Screenshot-Dashboard | GitLab - Chromium

Screenshot-New Project | GitLab - Chromium

Check if the repository is created.

[bash]
# ls /home/git/repositories/root/
abc.git abc.wiki.git
[/bash]

if the repository is not properly created.
Recreate a repository ,after restart service of GitLab.

[bash]
# service gitlab restart
[/bash]

Push to repository from other PC

Create a directory,and init Git repository.and create a sample file named README.
Examine to push to GitLab.

[bash]
$ mkdir abc
$ cd abc
$ git init
Initialized empty Git repository in /home/hiro/workspace/abc/.git/

$ git config user.name “myname”
$ git config user.email “myname@myhost.jp”
$ git remote add origin http://root@www.myhost.jp/gitlab/root/abc.git

$ echo “HELLO GITLAB” >>README
$ git add README
$ git commit -m “first commit”
$ git push -u origin master

[/bash]

Check the commit with Browser

Screenshot-Commits at master - Administrator - abc | GitLab - Chromium

Screenshot-Administrator - abc | GitLab - Chromium

Congratulations!!

About the author:

Related Posts

13 Comments

  1. rails developers  - 2014年7月28日 - 9:37 PM
    /

    Hello, I would like to subscribe for this blog to take latest updates,
    so where can i do it please help out.

  2. Solutions  - 2014年8月4日 - 5:32 AM
    /

    Hey There. I found your blog using msn. This is a very well written article.
    I will be sure to bookmark it and return to read more of
    your useful info. Thanks for the post. I will certainly comeback.

  3. web site  - 2014年8月12日 - 12:12 AM
    /

    This page truly has all of the information I needed concerning this subject and didn’t know who to ask.

  4. Leather Goods  - 2014年8月14日 - 7:03 PM
    /

    Link exchange is nothing else but it is just placing the other person’s webpage link on your page
    at suitable place and other person will also do same in favor of you.

  5. extreme peptides  - 2014年8月15日 - 6:32 AM
    /

    I’m not that much of a online reader to be honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back later on. Cheers

  6. Buy Cialis  - 2014年8月16日 - 6:41 AM
    /

    This is a good tip particularly to those
    fresh to the blogosphere. Short but very precise info…
    Thanks for sharing this one. A must read post!

  7. Foods To Avoid With IBS  - 2014年8月18日 - 2:26 PM
    /

    Hey! Would you mind if I share your blog with my twitter group?

    There’s a lot of people that I think would really appreciate your content.
    Please let me know. Many thanks

  8. taking surveys for money  - 2014年8月19日 - 9:13 PM
    /

    Pretty section of content. I just stumbled upon your site and in accession capital to claim that
    I acquire actually enjoyed account your blpg posts.

    Any way I will be subscribing in your augment or even I success you get entry to constantly rapidly.

  9. venus factor diet,  - 2014年8月23日 - 11:53 AM
    /

    Hmm it appears like your blog ate my first comment (it was super long)
    so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.

    I too am an aspiring blog blogger but I’m still new to the whole
    thing. Do you have any tips for inexperienced blog writers?
    I’d certainly appreciate it.

  10. Shirleen  - 2014年8月25日 - 4:44 PM
    /

    Hey! Do you use Twitter? I’d like to follow you if that would be
    okay. I’m definitely enjoying your blog and look foprward to neww updates.

  11. Weather  - 2014年8月26日 - 1:19 PM
    /

    It’s very straightforward to find out any matter
    on net as compared to books, as I found this piece of writing at this website.

  12. vedic math  - 2014年8月26日 - 10:43 PM
    /

    I got this web site from my friend who told me on the topic of tis web pagte and now this time
    I am visiting this website and resading very informative articles here.

  13. Holley Donten  - 2014年8月30日 - 12:14 PM
    /

    hi!,I like your writing so a lot! percentage we keep up a correspondence extra approximately your article on AOL? I need a specialist on this house to resolve my problem. Maybe that is you! Looking ahead to peer you.

Back to Top