Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • G gitlabhq1
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • gpt
  • large_projects
  • gitlabhq1
  • Issues
  • #663

Closed
Open
Created Apr 09, 2012 by Administrator@rootOwner

Issues and experiences in setting up gitlabhq on RedHat-based Linux distro

Created by: weijianwen

Hi, all. I'm a Scientific Linux (6.1) user, struggling to set up GitLab on my server. Several references are available there. There is a wiki discussing how to install gitlab (with gitosis) on Redhat-based Linux distros. Piotrek shares his experiences on installing gitlab on Fedora 16, using Apache as HTTP server. However, I prefer to follow the guide step by step, and my reasons are as follows: 1) gitosis is a bit too old, I want to try gitolite; 2) The guide is not so distro-specific and should work on RedHat-based Linux. Hopefully a unified installation guide for both Debian and RedHat Linux, will come out some day.

So in this post, I would like to share my "almost-finished" gitlab setups on Scientific Linux 6.1 (RedHat, Fedora, CentOS). My gitlab setup features:

  • Custom SSH port, e.g., use a port number other than 22 for SSH
  • gitolite (default git-backend in git's installation guide)
  • MySQL (I am more familiar with MySQL)

Thanks for help from github, Google and all the good guys like you, the following things work:

  • Start gitlab manually. gitlab is accessible via http://gitlab.mydomain.com:3000/
  • Log into gitlab with the default administrator account. User adding work fine.
  • The core functions work well: new repo, add SSH keys, clone/push/pull...

But as I mentioned, some parts don't work well. I'm new to RoR and nginx, therefore I'm looking for advice from you.

  • The initial script /etc/init.d/gitlab does not start gitlab properly.
  • Rails and nginx do not cooperate well. Visiting http://gitlab.mydomain.com returns 502 Bad Gateway.
  • git_status issue#662

In the rest of this post, I will show the process of installing gitlab on SC Linux. #1 (closed). Install packages

Install extra repos for Scientific Linux (SL).

$ sudo yum -y install rpmforge-release atrpms-repo epel-release
$ yum check-update  

Install packages for SC Linux. Equivalent packages for checkinstall and libcurl5-openssh-dev cannot be found on SL.

$ sudo yum -y install git-all wget curl gcc libxml2-devel libxslt-devel sqlite sqlite-devel libcurl libcurl-devel readline-devel mysql++-devel libicu-devel make zlib glibc-devel openssl python-devel python-pip sendmail redis

Start redis service and add redis to the default runlevel.

$ sudo service redis start
$ sudo chkconfig redis on

#2 (closed). Install ruby

Same as the guide. I had tried rvm, but rvm's unique rvmsudo makes things complicated. I dropped then decided to build ruby from source. #3 (closed). Install gitolite

There are some differences in command-line options. Notice: -c for description, /sbin/nologin for not-login account. By default, SL's useradd does not initailize a new account's password. That is to say, both git and ``gitlab` here cannot log into the server.

Create user for git:

sudo useradd \
  --system \
  --shell /bin/sh \
  -c 'git version control' \
  --home /home/git \
  git

Create user for gitlab:

sudo useradd --shell /sbin/nologin -c 'gitlab system' gitlab   

Add your user to git group:

sudo usermod -a -G git gitlab
sudo usermod -a -G git admin

Modify permission of gitlab's home dir, so that admin account can enter it.

sudo chmod a+x /home/gitlab

For custom SSH port other than 22: edit /home/gitlab/config, add the following code to it. Let's say you are using 30022 as your SSH port.

Host localhost
Port 30022

Then, gitlab will automatically use port 30022 to connect to ssh://git@localhost/gitolite-admin. I suggest NOT to specify the SSH port number explictly in the URL, such as ssh://git@localhost:30022/xxx -- this approach brings me lots of troubles.

Other parts are the same as the guide. #4 (closed). Install gitlab and configuration. Check status configuration.

Modify gitlab.yml to add some site information.

email:
  from: [email protected]
  host: gitlab.mydomain.com

  # Protocol used for links in email letters
  # Value can be http or https
  protocol: http # or https

# Git Hosting congiguration
git_host:
  system: gitolite
  admin_uri: git@localhost:gitolite-admin
  base_path: /home/git/repositories/
  host: gitlab.mydomain.com
  git_user: git
  # port: 22

The host and port in gitlag.yml will appear as parts of git repo address (Port number displays only if it's not the default value, 22). I repeat one more time here, DO NOT specify the SSH port number in the git uri. Just leave the port unchanged in gitlab.yml and set your SSH port in /home/gitlab/.ssh/config/.

I use MySQL database collocated with gitlab Rails on the same server. I set up a database name dbgitlab with username gitlab and password _PASSWORD_ (not real). For sercurity reason, this database can be only accessed from localhost. That's how I did it.

$ mysql -u root -p  # Log into MySQL with MySQL root account
mysql> CREATE DATABASE dbgitlab; 
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '_PASSWORD_';
mysql> GRANT ALL PRIVILEGES ON dbgitlab.* TO 'gitlab'@'localhost' WITH GRANT OPTION;
mysql> exit

Set database options in database.yml.

production:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  host: localhost
  database: dbgitlab
  pool: 5
  username: gitlab
  password: "_PASSWORD_"
  # socket: /tmp/mysql.sock

Everything else goes well in this port, except gitlab_status. I report it in issue#662. #5 (closed). Server up

Same as the guide. #6. Run resque process (for processing queue).

Add gitlab as a service and add it to default runlevel.

$ sudo chkconfig --add gitlab
$ sudo chkconfig gitlab on

But I don't start gitlab service here. Instead, after finishing all the required configurations, I manually start resque, unicorn, et al. for test.

$ sudo -u gitlab bundle exec rails s -e production -d
$ sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
$ sudo -u gitlab bundle exec unicorn_rails -c config/unicorn.rb -E production -D

I see ruby is listening on port 3000, nginx on port 80. http://gitlab.mydomain.com:3000 brings me to the lovely gitlab homepage. Good. But wait, http://gitlab.mydomain.com returns "502 Bad Gateway".

sudo /etc/init.d/gitlab restart or sudo pkill ruby; sudo /etc/init.d/gitlab start don't help. What's worse, sudo /etc/init.d/gitlab start prompts no error, but I can not visit http://gitlab.mydomain.com:3000 -- now ruby is not listening on port 3000. In order to use gitlab, I have to start it mannualy. Sound bad.

Here is the stderr log for unicorn when I run sudo /etc/init.d/gitlab start.

$ cat /home/gitlab/gitlab/log/unicorn.stderr.log 
I, [2012-04-09T17:33:52.319914 #4835]  INFO -- : listening on addr=/home/gitlab/gitlab//tmp/sockets/gitlab.socket fd=3
I, [2012-04-09T17:33:52.321151 #4835]  INFO -- : Refreshing Gem list
I, [2012-04-09T17:34:12.373107 #4835]  INFO -- : master process ready
I, [2012-04-09T17:34:12.583440 #4845]  INFO -- : worker=0 ready
I, [2012-04-09T17:34:12.627225 #4848]  INFO -- : worker=1 ready
I, [2012-04-09T18:49:36.332550 #4835]  INFO -- : reaped #<Process::Status: pid 4845 exit 0> worker=0
I, [2012-04-09T18:49:36.332741 #4835]  INFO -- : reaped #<Process::Status: pid 4848 exit 0> worker=1
I, [2012-04-09T18:49:36.332930 #4835]  INFO -- : master complete
I, [2012-04-09T19:18:10.269533 #12431]  INFO -- : unlinking existing socket=/home/gitlab/gitlab//tmp/sockets/gitlab.socket
I, [2012-04-09T19:18:10.270222 #12431]  INFO -- : listening on addr=/home/gitlab/gitlab//tmp/sockets/gitlab.socket fd=3
I, [2012-04-09T19:18:10.270877 #12431]  INFO -- : Refreshing Gem list
I, [2012-04-09T19:18:30.486118 #12431]  INFO -- : master process ready
I, [2012-04-09T19:18:30.525985 #12441]  INFO -- : worker=0 ready
I, [2012-04-09T19:18:30.551131 #12444]  INFO -- : worker=1 ready
Assignee
Assign to
Time tracking