Environment preparation
Python 2.6
Git version 1.8.4.1
Ruby version ruby-2.0.0-p353
Gitlab-shell v1.8.0
Gitlab version 6.4.3
Because the python version of centos6 series is 2.6 and is supported, you do not need to upgrade python.
Upgrade python version> 2.5 under centos5
Install epel yum source
Yum-y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Install necessary software packages
Yum-y install libicu-devel patch gcc-c ++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
Link: http://www.linuxyan.com/web-server/353.html
Install git
Because git requires version 1.8 or later, you need to re-compile and install it.
Remove current git
Yum remove git
Download and install git 1.8.4.1
Curl -- progress https://git-core.googlecode.com/files/git-1.8.4.1.tar.gz | tar xz Z
Cd git-1.8.4.1/
Make prefix =/usr/local all
Make prefix =/usr/local install
Ln-fs/usr/local/bin/git */usr/bin/
Install the ruby environment
Yum-y remove ruby
Mkdir/tmp/ruby & cd/tmp/ruby
Curl -- progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz Z
Cd ruby-2.0.0-p353/
./Configure -- disable-install-rdoc
Make & make install
Gem source-r https://rubygems.org/
Gem source-a http://ruby.taobao.org/
Gem install bundler -- no-ri -- no-rdoc
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
Add a git account and allow sudo
Useradd -- comment 'gitlab 'git
Echo "git ALL = (ALL) NOPASSWD: ALL">/etc/sudoers
Install git-shell
Cd/home/git
Sudo-u git-H git clone https://gitlab.com/gitlab-org/gitlab-shell.git-B v1.8.0
Cd gitlab-shell/
Sudo-u git-H cp config. yml. example config. yml
Vim config. yml
Change gitlab_url to The gitlab domain name
Gitlab_url: "http: // localhost /"
Change
Gitlab_url: "The http://git.linuxyan.com /"
# Install git-shell
Sudo-u git-H./bin/install
Install mysql and create a gitlab Database
Yum install mysql-devel mysql-server-y
/Etc/init. d/mysqld start
Chkconfig mysqld on
Log on to mysql to create a gitab account and database.
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 ';
Test whether you can log on to the database with a git account
Sudo-u git-H mysql-u gitlab-p-D gitlabhq_production
Install redis
Yum-y install redis
/Etc/init. d/redis start
Chkconfig redis on
Install gitlab
Cd/home/git
Sudo-u git-H git clone https://gitlab.com/gitlab-org/gitlab-ce.git-B 6-4-stable gitlab
Cd/home/git/gitlab
Sudo-u git-H cp config/gitlab. yml. example config/gitlab. yml
Vim config/gitlab. yml
Modify host to the domain name set in git-shell.
# GitLab settings
Gitlab:
# Web server settings
Host: git.linuxyan.com
Port: 80
Https: false
Modify the path of git
Git:
Bin_path:/usr/local/bin/git
Add permissions to folders
Chown-R git log/
Chown-R git tmp/
Chmod-R u + rwX log/
Chmod-R u + rwX tmp/
Create necessary folders and copy configuration files
Sudo-u git-H mkdir/home/git/gitlab-satellites
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/
Sudo-u git-H mkdir public/uploads
Sudo chmod-R u + rwX public/uploads
Sudo-u git-H cp config/unicorn. rb. example config/unicorn. rb
Sudo-u git-H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
Set a global account for gitlab
Sudo-u git-H git config -- global user. name "GitLab"
Sudo-u git-H git config -- global user. email "gitlab @ localhost"
Sudo-u git-H git config -- global core. autocrlf input
Set Database link addresses and permissions
Sudo-u git cp config/database. yml. mysql config/database. yml
Sudo-u git-H vim config/database. yml
Modify connected database information
Production:
Adapter: mysql2
Encoding: utf8
Reconnect: false
Database: gitlabhq_production
Pool: 10
Username: gitlab
Password: "gitlab"
# Host: localhost
# Socket:/tmp/mysql. sock
Install gems for ruby
Cd/home/git/gitlab
Vim Gemfile
Modify source "https://rubygems.org /"
For source "http://ruby.taobao.org /"
Vim Gemfile. lock
Modify remote: https://rubygems.org/
For remote: http://ruby.taobao.org/
Install
Sudo-u git-H bundle install -- deployment -- without development test postgres aws
If the following error occurs:
Cocould not find modernizr-2.6.2 in any of the sources
Modify:
Vim Gemfile
Modify: gem "modernizr", "2.6.2"
For gem "modernizr-rails", "2.7.1"
Vim Gemfile. lock
Modify: modernizr (2.6.2)
Modernizr-rails (2.7.1)
Modify: modernizr (= 2.6.2)
Modernizr-rails (= 2.7.1)
Then execute the installation
Sudo-u git-H bundle install -- deployment -- without development test postgres aws
Initialize database
Sudo-u git-H bundle exec rake gitlab: setup RAILS_ENV = production
After the database is initialized, you will be notified of the default administrator user and password:
Install the startup file and log cutting file
Cp lib/support/init. d/gitlab/etc/init. d/gitlab
Cp lib/support/init. d/gitlab. default. example/etc/default/gitlab
Cp lib/support/logrotate/gitlab/etc/logrotate. d/gitlab
Check the current environment
Sudo-u git-H bundle exec rake gitlab: env: info RAILS_ENV = production
Install nginx
Yum-y install nginx
Modify the configuration file:
Vim/etc/nginx. conf
User root git;
Worker_processes 2;
Pid/var/run/nginx. pid;
Events {
Worker_connections 1024;
}
Http {
Include/etc/nginx/mime. types;
Default_type application/octet-stream;
Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';
# GITLAB
# Maintainer: @ randx
# App Version: 5.0
Upstream gitlab {
Server unix:/home/git/gitlab/tmp/sockets/gitlab. socket;
}
Server {
Listen *: 80 default_server; # e.g., listen 192.168.1.1: 80; In most cases *: 80 is a good idea
Server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com;
Server_tokens off; # don't show the version number, a security best practice
Root/home/git/gitlab/public;
# Set value of client_max_body_size to at least the value of git. max_size in gitlab. yml
Client_max_body_size 5 m;
# Individual nginx logs for this gitlab vhost
Access_log/var/log/nginx/gitlab_access.log;
Error_log/var/log/nginx/gitlab_error.log;
Location /{
# Serve static files from defined root folder ;.
# @ Gitlab is a named location for the upstream fallback, see below
Try_files $ uri/index.html unzip uri.html @ gitlab;
}
# If a file, which is not found in the root folder is requested,
# Then the proxy pass the request to the upsteam (gitlab unicorn)
Location @ gitlab {
Proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
Proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694
Proxy_redirect off;
Proxy_set_header X-Forwarded-Proto $ scheme;
Proxy_set_header Host $ http_host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Proxy_pass http: // gitlab;
}
}
}
Change permissions and start nginx
Nginx-t
Chown-R git. git/var/lib/nginx/
/Etc/init. d/nginx start
Pull gitlab static resource files
Sudo-u git-H bundle exec rake assets: precompile RAILS_ENV = production
Start gitlab
/Etc/init. d/gitlab start
Check whether each component works properly
Sudo-u git-H bundle exec rake gitlab: check RAILS_ENV = production
If no error is detected, gitlab has been installed,
At this time you can open the http://git.linuxyan.com with a browser
The initial administrator account and password are:
Admin@local.host
5 iveL! Fe