CentOS Git Server Installation tutorial
Install yum Source
Yum-y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Vim/etc/yum. repos. d/epel. repo
Baseurl remove comment
Comment into list
Install the package required by the git Environment
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
Remove existing git ruby from the machine
Yum-y remove git ruby
Install git
Mkdir/tmp/git & cd/tmp/git
Wget https://www.kernel.org/pub/software/scm/git/git-1.8.4.1.tar.gz
Tar-zxvf git-1.8.4.1.tar.gz
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 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
Create a git account and allow sudo
Useradd -- comment 'gitlab 'git
Echo "git ALL = (ALL) NOPASSWD: ALL">/etc/sudoers
Install git-shell
Su-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
Modify gitlab Domain Name
Gitlab_url: "http: // localhost /"
For example:
Gitlab_url: "http://gitlab.example.com/"
: Wq!
Sudo-u git-H./bin/install
Use mysql and create a gitlab database. If the local machine does not have mysql, directly install yum.
Sudo yum-y install mysql-devel mysql-server
Sudo/etc/init. d/mysqld start
Mysql-uroot-p
Create user 'gituser' @ 'localhost' identified by 'gitpasswd ';
Create database if not exists 'gitlabhq _ production 'default character set 'utf8' COLLATE 'utf8 _ unicode_ci ';
Grant select, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, alter on 'gitlabhq _ production '. * TO 'gituser' @ 'localhost ';
\ Q
Test whether gituser logs on to the database normally
Sudo-u git-H mysql-u gituser-p-D gitlabhq_production
Install redis
Sudo yum-y install redis
Sudo/etc/init. d/redis start
Sudo 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 the git domain name, as defined in the above git-shell configuration file
Gitlab:
# Web server settings
Host: gitlab.example.com
Port: 80
Https: false
Modify git path
Git:
Bin_path:/usr/local/bin/git
: Wq!
Add permissions for the corresponding file, create necessary files, and copy the configuration file
Chown-R git log/
Chown-R git tmp/
Chmod-R u + rwX log/
Chmod-R u + rwX tmp/
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
Configure the database connection file as follows:
Sudo-u git cp config/database. yml. mysql config/database. yml
Sudo-u git-H vim config/database. yml
#
# PRODUCTION
#
Production:
Adapter: mysql2
Encoding: utf8
Reconnect: false
Database: gitlabhq_production
Pool: 10
Username: gituser
Password: "gitpasswd"
# Host: localhost
# Socket:/tmp/mysql. sock
#
# Development specific
#
Development:
Adapter: mysql2
Encoding: utf8
Reconnect: false
Database: gitlabhq_development
Pool: 5
Username: gituser
Password: "gitpasswd"
# Socket:/tmp/mysql. sock
# Warning: The database defined as "test" will be erased and
# Re-generated from your development database when you run "rake ".
# Do not set this db to the same as development or production.
Test: & test
Adapter: mysql2
Encoding: utf8
Reconnect: false
Database: gitlabhq_test
Pool: 5
Username: gituser
Password: "gitpasswd"
# Socket:/tmp/mysql. sock
Install gems
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/
: Wq
Sudo-u git-H bundle install -- deployment -- without development test postgres aws
If this 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"
: Wq
Vim Gemfile. lock
Modify: modernizr (2.6.2)
Modernizr-rails (2.7.1)
Modify: modernizr (= 2.6.2)
Modernizr-rails (= 2.7.1)
: Wq
Run again: 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
Do you want to continue (yes/no )? Yes
The last two lines after initialization are your default gitlab username and password.
Configure startup and log cutting files
Sudo cp lib/support/init. d/gitlab/etc/init. d/gitlab
Sudo cp lib/support/init. d/gitlab. default. example/etc/default/gitlab
Sudo cp lib/support/logrotate/gitlab/etc/logrotate. d/gitlab
Test Environment Information
Sudo-u git-H bundle exec rake gitlab: env: info RAILS_ENV = production
Install nginx
Sudo yum-y install nginx
The following is the content of my nginx main configuration file
Cat/etc/nginx. conf | grep-v "^ #" | grep-v "^ $"
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 "';
Upstream gitlab {
Server unix:/home/git/gitlab/tmp/sockets/gitlab. socket;
}
Server {
Listen *: 80 default_server;
Server_name gitlab.example.com;
Server_tokens off;
Root/home/git/gitlab/public;
Client_max_body_size 5 m;
Access_log/var/log/nginx/gitlab_access.log;
Error_log/var/log/nginx/gitlab_error.log;
Location /{
Try_files $ uri/index.html unzip uri.html @ gitlab;
}
Location @ gitlab {
Proxy_read_timeout 300;
Proxy_connect_timeout 300;
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;
}
}
# Tcp_nopush on;
# Keepalive_timeout 0;
# Gzip on;
# Load config files from the/etc/nginx/conf. d directory
# The default server is in conf. d/default. conf
}
Change permissions and start nginx
Sudo nginx-t
Sudo chown-R git. git/var/lib/nginx/
Sudo/etc/init. d/nginx start
Pull gitlab static resource files
Sudo-u git-H bundle exec rake assets: precompile RAILS_ENV = production
Start gitlab
Sudo/etc/init. d/gitlab start
Check whether each component works properly
Sudo-u git-H bundle exec rake gitlab: check RAILS_ENV = production
If everything is normal, use your browser to access gitlab (Domain Name access, modify the hosts file first)
Http://gitlab.example.com
The account password is the account password displayed after the above initialization data
Admin@local.host/5 iveL! Fe
Gitlab installation is complete.