Debian under Gitlab installation steps detailed

Source: Internet
Author: User
Tags chmod create directory curl hash redis tar xz create database git clone

Blog is not updated for a long time, taking advantage of the mid-Autumn holiday home study installed Gitlab. This toss ah, then write a note, the next can be referred to.
Basically refer to official documentation: HTTPS://GITHUB.COM/GITLABHQ/GITLABHQ/BLOB/MASTER/DOC/INSTALL/INSTALLATION.MD and then some places to pay attention to do the record.

First, installation requirements

debian**
Mysql
Git
Gitlab-shell
Redis
Second, installation tutorials

1. First need to determine the account can use sudo, and update the System package
# Run as root!
Apt-get Update
Apt-get Upgrade
Apt-get install sudo #正常情况系统都带sudo命令 if not, manually installed under
2. Install some necessary packages
sudo apt-get install-y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev Libreadline-dev Libncurses5-dev Lib Ffi-dev Curl Openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate Python-docutils Pkg-config CMake
Check the Python version, 2.5+ (3.0+ not supported) Python--version
If the version is not correct, please install

sudo apt-get install python2.7
Python2--version
sudo ln-s/usr/bin/python/usr/bin/python2
Install Mail Send support defaults

sudo apt-get install-y postfix
3. Install Ruby Here we use the Taobao image to install can greatly shorten the download package time
Mkdir/tmp/ruby && Cd/tmp/ruby
Curl--progress http://ruby.taobao.org/mirrors/ruby/2.1/ruby-2.1.2.tar.gz | Tar XZ
CD ruby-2.1.2
./configure--disable-install-rdoc
Make
sudo make install
Note: Do not use RVM to install Ruby It may cause such errors because of environment variables, of course, if you can solve these problems you can use RVM to install Ruby
Install bundler Here we also use Taobao mirroring to shorten the download time, note please use sudo!!

sudo gem sources--remove http://rubygems.org/
sudo gem sources-a http://ruby.taobao.org/
sudo gem install bundler
4. Add git user
sudo adduser–disabled-login–gecos ' Gitlab ' git

5. Install Gitlab-shell new version use Gitlab-shell to replace Gitolite
# Login as Git
sudo su git

# Go to home directory
Cd/home/git

# Clone Gitlab Shell
git clone https://github.com/gitlabhq/gitlab-shell.git

CD Gitlab-shell

# Switch to right version
git checkout v1.4.0

CP Config.yml.example CONFIG.YML

# Edit config and replace Gitlab_url
# with something like ' http://domain.com/'
# here to modify into their own internal domain names such as: http://git.test.com/
Vim Config.yml

# do Setup
./bin/install
6. Installation database recommended MySQL
All of the following operations require the use of sudo accounts

# Install the database packages
sudo apt-get install-y mysql-server mysql-client Libmysqlclient-dev

# Login to MySQL
Mysql-u root-p

# Create a user for Gitlab. (Change $password to a real password)
mysql> CREATE USER ' gitlab ' @ ' localhost ' identified by ' 123456 ';

# Create the Gitlab production database
mysql> CREATE DATABASE IF not EXISTS ' gitlabhq_production ' DEFAULT CHARACTER SET ' UTF8 ' COLLATE ' utf8_unicode_ci ';

# Grant The Gitlab user necessary permissions on the table.
Mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER on ' gitlabhq_production '. * to ' git Lab ' @ ' localhost ';
7. Start installing Gitlab Main program
# # We ' ll install Gitlab into home directory of the user ' git '
Cd/home/git

# Clone Gitlab Repository
Sudo-u git-h git clone https://github.com/gitlabhq/gitlabhq.git Gitlab

# Go to Gitlab dir
Cd/home/git/gitlab

# Checkout to stable release
Sudo-u git-h git checkout 7-2-stable
8. Configure Gitlab
# Go to Gitlab installation folder
Cd/home/git/gitlab

# Copy The example Gitlab Config
Sudo-u git-h CP config/gitlab.yml.example CONFIG/GITLAB.YML

# Make sure to change ' localhost ' to the fully-qualified domain name of your
# Host serving Gitlab where necessary
# Here you only need to modify the host,
Sudo-u git-h Vim Config/gitlab.yml

# Make sure Gitlab can write to the Log/and tmp/directories
# Modify Account Permissions
sudo chown-r git log/
sudo chown-r git tmp/
sudo chmod-r u+rwx log/
sudo chmod-r u+rwx tmp/

# Create Directory for satellites
Sudo-u git-h Mkdir/home/git/gitlab-satellites
sudo chmod u+rwx,g=rx,o-rwx/home/git/gitlab-satellites

# Create directories for Sockets/pids and make sure Gitlab can write to them
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 Public/uploads Directory otherwise backup would fail
Sudo-u git-h mkdir public/uploads
sudo chmod-r u+rwx public/uploads

# Copy The example Puma Config
Sudo-u git-h CP config/puma.rb.example CONFIG/PUMA.RB

# Copy The example Puma Config
# This configuration file defaults to
Sudo-u git-h Vim config/puma.rb

#如果没有puma. RB can use the following, two to select a
Sudo-u git-h CP config/unicorn.rb.example CONFIG/UNICORN.RB
Sudo-u git-h Editor Config/unicorn.rb
# listen "142.23.21.76:8080",: Tcp_nopush => True

# Copy The example Rack attack config
Sudo-u git-h CP config/initializers/rack_attack.rb.example CONFIG/INITIALIZERS/RACK_ATTACK.RB

# Configure git global settings for git user, useful when editing via web
# Edit User.email According to what be set in Gitlab.yml
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

Sudo-u git cp config/database.yml.mysql config/database.yml

# Modify the database account password, just added gitlab this database user directly modified into the account can be
Sudo-u git vim config/database.yml
#数据库密码 only need to modify production
# Username:gitlab
# Password: "123456"
# Host:localhost
9. Install Gems
Cd/home/git/gitlab

sudo gem install charlock_holmes--version ' 0.6.9.4 '

# Modify bundle Source address for Taobao, change the first line to source ' http://ruby.taobao.org/'
Sudo-u git vim gemfile

# This is the use of MySQL database, this command means to exclude postgres please don't be mistaken
Sudo-u git-h Bundle Install--deployment--without Development Test Postgres AWS
10. Initialize the database and enable advanced features
Sudo-u git-h bundle exec Rake Gitlab:setup rails_env=production
11. Install Init script
Cd/home/git/gitlab
sudo curl--output/etc/init.d/gitlab Https://raw.github.com/gitlabhq/gitlabhq/7-2-stable/lib/support/init.d/gitlab
CP lib/support/init.d/gitlab/etc/init.d/
sudo chmod +x/etc/init.d/gitlab

#设置开机启动GitLab
sudo update-rc.d gitlab defaults 21

Cd/home/git/gitlab
CP Lib/support/logrotate/gitlab/etc/logrotate.d/gitlab
12. Finally check the status of the program
CD Gitlab
Sudo-u git-h bundle exec Rake Gitlab:check rails_env=production
Note: This may tell you that there is a problem with the Init script or the GIT version is too low to ignore

13. Start Gitlab
sudo service Gitlab start
Third, nginx configuration

You can install Nginx to delegate access to the Gitlab configuration process as follows

1. Install Nginx
sudo apt-get install Nginx
Cd/home/git/gitlab
1. Add Gitlab configuration file
sudo curl--output/etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlabhq/7-2-stable/lib/ Support/nginx/gitlab
sudo cp lib/support/nginx/gitlab/etc/nginx/sites-available/
sudo ln-s/etc/nginx/sites-available/gitlab/etc/nginx/sites-enabled/gitlab

# Modify configuration file Listen directly listen to the 80 port e.g. Listen 80;
# Modify server_name for your internal domain name e.g. server_name git.test.com;
sudo vim/etc/nginx/sites-available/gitlab
2. Restart Nginx
sudo service nginx restart
The hash table that holds the server name is controlled by instruction Server_names_hash_max_size and server_names_hash_bucket_size. The parameter hash bucket size is always equal to the size of the hash table and is a multiple of the processor cache size. If Nginx gives a hint that you need to increase the size of the hash max size or hash bucket, it is important to increase the magnitude of the previous argument.

Vim/etc/nginx/sites-enabled/gitlab
Server_names_hash_bucket_size 64;
sudo service nginx restart
So you can visit Gitlab through Nginx.
The default account is as follows

User name: Admin@local.host
Password: 5ivel!fe

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.