Install Gitlab5.1 full version in CentOS

Source: Internet
Author: User
Tags install perl

Install Gitlab5.1 full version in CentOS

I found many blogs and found that Gitlab is installed on Ubuntu or Fedora. Basically, there are errors Based on CentOS. This article is myThe results of the two-week Continuous testing work overtime are installed according to this article.

System Environment: CentOS 5.8 x86_64

There are several steps

1. Install the dependency package

2. Install Ruby, bundle, and Python

3. Create a git user

4. Install Gitlab-Shell

5. Install the database

6. Install Gitlab

7. Install Nginx

1. Install the dependency package

1.1 import yum Source

Yum-y update

Yum-y install perl *

Import epel Source

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

1.2 install dependency packages

yum groupinstall "Development Tools" -y
yum install kernel-devel \ kernel-headers \ zlib-devel \ libyaml-devel \ openssl-devel \ gdbm-devel \ readline-devel \ ncurses-devel \ libffi-devel \ git \ curl \ openssh-server \ redis \ postfix \ libxml2-devel \ libxslt-devel \ perl-Time-HiRes \ curl-devel \ libicu-devel \ mysql-devel -y

If information appears after the epel source is imported, modify the/etc/yum. repos. d/epel. repo file.
Remove the # Before base and add the # Before mirror, as shown in the complete figure:
 
 
2. Install Ruby, Bundle, and Python
2.1 install ruby
mkdir /tmp/ruby && cd /tmp/rubycurl --progress http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | tar xzcd ruby-1.9.3-p392./configuremakemake install

2.2 install Bundler Gem

gem install bundler

Special attention !!!

After Ruby and bundle are installed, perform the following operations. Otherwise, a bunch of operations will be performed later:

Sudo: gem: command not found and

/Usr/bin/env: ruby: No such file or directory, cocould not locate Gemfile

Exhausted, remember !!!

OPERATIONS:

Ln-s/usr/local/bin/ruby/usr/bin/ruby ln-s/usr/local/bin/gem/usr/bin/gem ln-s/usr/ local/bin/bundle/usr/bin/bundle

2.3 install Python2.7.2

Follow http://tz100.me/135.html.

3. Create a Git user

useradd -c 'GitLab' git

Mongodo

Add a row

Git ALL = (ALL) NOPASSWD: ALL

4. Install Gitlab-Shell

Download gitlab-shell

cd /home/gitsudo -u git -H git clone https://github.com/gitlabhq/gitlab-shell.git

Switch to the stable gitlab-shell version suitable for gitlab5.1

cd /home/git/gitlab-shellsudo -u git -H git checkout v1.3.0sudo -u git -H cp config.yml.example config.yml

Copy the configuration file

sudo -u git -H cp config.yml.example config.yml

Edit the configuration file and change the line "gitlab_url: http: // localhost/" to your domain name or IP address.

Note: I used IP addresses for testing.

sudo -u git -H vi config.yml

As shown in:

Note: Do not remove the last part of the URL!

Install gitlab-shell

sudo -u git -H ./bin/install

The installation result page is as follows:

5. Create a database (based on mysql)

yum install mysql mysql-devel mysql-server -y

Start mysql and set the password

Service mysqld startmysqladmin-u root password 'your password'

Connect to mysql for database settings

mysql -u root -p

=

mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY 'gitlab';mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';mysql> \q

Test connection

[root@mytest123 gitlab-shell]# sudo -u git -H mysql -u gitlab -p -D gitlabhq_productionEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 5Server version: 5.0.95 Source distributionCopyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> \q

6. Install Gitlab

Download the source code and switch to stable version 5.1

cd /home/gitsudo -u git -H git clone https://github.com/gitlabhq/gitlabhq.git gitlabcd /home/git/gitlabsudo -u git -H git checkout 5-1-stable

Configure

cd /home/git/gitlabsudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

Edit the gitlab. yml file and change host: localhost to your domain name or IP address (IP Address used ),

sudo -u git -H vi config/gitlab.yml

Grant the GIT user the required GITLAB directory and permissions

[root@mytest123 gitlab]# sudo chown -R git -R log [root@mytest123 gitlab]# sudo chown -R git -R tmp[root@mytest123 gitlab]# sudo chmod -R u+rwX log/[root@mytest123 gitlab]# sudo chmod -R u+rwX tmp/

Create a satellites directory

# sudo -u git -H mkdir /home/git/gitlab-satellites

Create a PID directory and grant permissions

sudo -u git -H mkdir tmp/pids/sudo -u git -H mkdir tmp/sockets/sudo chmod -R u+rwX tmp/pids/sudo chmod -R u+rwX tmp/sockets/

Create the upload directory. If the directory is not set up, the backup function will fail.

sudo -u git -H mkdir public/uploadssudo chmod -R u+rwX public/uploads

Copy the PUma configuration file

sudo -u git -H cp config/puma.rb.example config/puma.rb

Copy the database configuration file and edit and modify the username and password in the file to the database user and password you just created.

sudo -u git cp config/database.yml.mysql config/database.ymlsudo -u git -H vi config/database.yml

:

Install the required Gems

cd /home/git/gitlabsudo gem install charlock_holmes --version '0.6.9'sudo -u git -H bundle install --deployment --without development test postgres

Bundle install will install a lot of dependent packages. wait patiently and give two images.

Configure global variables for GIT users

sudo -u git -H git config --global user.name "GitLab"sudo -u git -H git config --global user.email "gitlab@YOUR_DOMAIN_NAME"

Start redis

Note: I do not understand why redis is needed. It is said that advanced features are required.

service redis start

Initialize Database

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

If no error occurs, the default gitlab user and password will appear. Record the password so that you can log on

Install the Startup Script

curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab
chmod +x /etc/init.d/gitlab

Run check

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=productionsudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

If the check fails, do not start it. Fix it based on the check result. The red color of the operating system does not matter.

If

Because redis is not started,

service gitlab startRun the check again.

Start

sudo service mysqld startsudo service redis startsudo service gitlab start

Note: If the preceding user and password are displayed, the Gitlab installation in this step will be successful, but it can only use port 3000 and nginx, that is to say, gitlab-shell cannot be called, so it has not been fully called;

If it is acute, you can start debugging first, but I suggest you do not start it until nginx debugging is complete.

bundle exec rails s -e production

Code:

[root@mytest123 ~]# su -gitsu: invalid option -- gTry `su --help' for more information.[root@mytest123 ~]# su - git[git@mytest123 ~]$ cd gitlab[git@mytest123 gitlab]$ bundle exec rails s -e production -d/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin in PATH, mode 040777/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/runtime.rb:216: warning: Insecure world writable dir /home/git/gitlab/vendor/bundle/ruby/1.9.1/bin in PATH, mode 040777=> Booting WEBrick=> Rails 3.2.13 application starting in production on http://0.0.0.0:3000[git@mytest123 gitlab]$

7. Install nginx

yum install nginx -y

Download gitlab's nginx configuration file

 curl --output /etc/nginx/conf.d/gitlab.conf https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/nginx/gitlab

Edit the file and paste the two lines

Listen YOUR_SERVER_IP: 80 default_server; # e.g., listen 192.168.1.1: 80;
Server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;

Change it to your domain name or IP address. my options are as follows:

Start nginx and access it with a domain name or IP address. The first error "502 Bad Gateway" was reported. Check gitlab_err.log as follows:

[Root @ mytest123 gitlab] # tail-f/var/log/nginx/gitlab_error.log
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", host: "192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public // index.html" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", host: "192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public /. html "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 connect () to unix:/home/git/gitlab/tmp/sockets/gitlab. socket failed (13: Permission denied) while connecting to upstream, client: 180.159.220.7, server: 192.161.57.96, request: "GET/HTTP/1.1", upstream: "http: // unix: /home/git/gitlab/tmp/sockets/gitlab. socket:/", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon. ico "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon. ico/index.html "failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request:" GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 stat () "/home/git/gitlab/public/favicon.ico.html" failed (13: Permission denied), client: 180.159.220.7, server: 192.161.57.96, request: "GET/favicon. ico HTTP/1.1 ", host:" 192.161.57.96 ″
10:09:49 [crit] 4003 #0: * 1 connect () to unix:/home/git/gitlab/tmp/sockets/gitlab. socket failed (13: Permission denied) while connecting to upstream, client: 180.159.220.7, server: 192.161.57.96, request: "GET/favicon. ico HTTP/1.1 ", upstream:" http: // unix:/home/git/gitlab/tmp/sockets/gitlab. socket:/favicon. ico ", host:" 192.161.57.96 ″

There are two main points to be modified, and the/home/git/gitlab/directory should be granted permissions, and then:/home/git/gitlab/tmp/sockets/gitlab. you must also grant permissions to the socket file. I will grant permissions to the gitlab directory 777 directly.

[root@mytest123 gitlab]# chmod -R 777 /home/git/gitlab/

Restart gitlab and nginx and access again

Succeeded. The page is displayed ~

The command line check through gitlab-shell is successful, yeah!

[Root @ mytest123 git] # su-git
[Git @ mytest123 ~] $ Cd gitlab-shell/
[Git @ mytest123 gitlab-shell] $./bin/check
Check GitLab API access: OK
Check directories and files:
/Home/git/repositories: OK
/Home/git/. ssh/authorized_keys: OK
[Git @ mytest123 gitlab-shell] $

Reference: https://gist.github.com/wakefield/5304650

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.