Install Gitlab on Ubuntu

Source: Internet
Author: User
1. Installation Package apt-getupdate & amp; apt-getupgrade & amp; apt-getinstallsudosudoapt-getupdatesudoapt-getupgradesudoapt-getinstall-ywgetcurlgcccheckinstalllibxm

1. installation package under root permission
 
Apt-get update & apt-get upgrade & apt-get install sudo
 
Sudo apt-get update
Sudo apt-get upgrade
 
Sudo apt-get install-y wget curl gcc checkinstall libxml2-dev libxslt-dev sqlite3 libsqlite3-dev libcurl4-openssl-dev libreadline6-dev libc6-dev libssl-dev libmysql ++-dev make build-essential zlib1g-dev libicu-dev redis-server openssh -server git-core python-dev python-pip libyaml-dev postfix
 
# If you use MySQL to execute:
Sudo apt-get install-y mysql-server mysql-client libmysqlclient-dev
 
 
2. Install Ruby
Wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz
Tar xfvz ruby-1.9.3-p194.tar.gz
Cd ruby-1.9.3-p194
./Configure
Make
Sudo make install
 
3. Install Gitolite
Create a git account:
 
Sudo adduser \
-- System \
-- Shell/bin/sh \
-- Gecos 'git version control '\
-- Group \
-- Disabled-password \
-- Home/git \
Git
 
Create a GitLab account:
 
# Ubuntu/debian
Sudo adduser -- disabled-login -- gecos 'gitlab system' gitlab
Add your user to the git group:
 
Sudo usermod-a-G git gitlab
Generate key:
 
Sudo-H-u gitlab ssh-keygen-q-N'-t rsa-f/home/gitlab/. ssh/id_rsa
Clone GitLab's fork of the Gitolite source code:
 
Cd/home/git
Sudo-H-u git clone-B gl-v304 https://github.com/gitlabhq/gitolite.git/home/git/gitolite
 
Installation:
 
Cd/home/git
Sudo-u git-H mkdir bin
Sudo-u git sh-c 'echo-e "PATH = \ $ PATH:/home/git/bin \ nexport PATH">/home/git/. profile'
Sudo-u git sh-c 'gitolite/install-ln/home/git/bin'
 
Sudo cp/home/gitlab/. ssh/id_rsa.pub/home/git/gitlab. pub
Sudo chmod 0444/home/git/gitlab. pub
 
Sudo-u git-H sh-c "PATH =/home/git/bin: $ PATH; gitolite setup-pk/home/git/gitlab. pub"
Sudo-u git-H sed-I's/0077/0007/G'/home/git/. gitolite. rc
Permissions:
 
Sudo chmod-R g + rwX/home/git/repositories/
Sudo chown-R git: git/home/git/repositories/
CHECK: Logout & login again to apply git group to your user
 
# Clone admin repo and add localhost to hosts
# Make sure you can access gitolite
Sudo-u gitlab-H git clone git @ localhost: gitolite-admin.git/tmp/gitolite-admin
 
# If yes, remove/tmp/gitolite-admin
Sudo rm-rf/tmp/gitolite-admin
IMPORTANT! If you can't clone gitolite-admin repository-do not proceed with installation Check the Trouble Shooting Guide and ensure you have followed all of the above steps carefully.
 
4. Clone GitLab code
Sudo gem install charlock_holmes -- version '0. 6.8'
Sudo pip install pygments
Sudo gem install bundler
Cd/home/gitlab
 
# Get GitLab code
Sudo-H-u gitlab GitHub clone-B stable https://github.com/gitlabhq/gitlabhq.git gitlab
 
#
# Master branch (recent changes, less stable)
Sudo-H-u gitlab git clone-B master https://github.com/gitlabhq/gitlabhq.git gitlab
 
Cd gitlab
 
# Rename the configuration file
Sudo-u gitlab cp config/gitlab. yml. example config/gitlab. yml
Select the database you want to use
 
# Using SQLite
Sudo-u gitlab cp config/database. yml. sqlite config/database. yml
 
# Or use MYSQL
# Install MySQL before using MYSQL
 
# Login to MySQL
$ Mysql-u root-p
 
# Create a GitLab production database
Mysql> create database if not exists 'gitlabhq _ production 'default character set 'utf8' COLLATE 'utf8 _ unicode_ci ';
 
# Create a MYSQL account $ password and change it to your password
Mysql> create user 'gitlab '@ 'localhost' identified by' $ password ';
 
# Grant permissions to this account
Mysql> grant select, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, alter on 'gitlabhq _ production '. * TO 'gitlab' @ 'localhost ';
 
# Update the MYSQL password to the config/database. yml file.
Sudo-u gitlab cp config/database. yml. example config/database. yml
Install gems
 
Sudo-u gitlab-H bundle install -- without development test -- deployment
Setup database
 
Sudo-u gitlab bundle exec rake gitlab: app: setup RAILS_ENV = production
Setup GitLab hooks
 
Sudo cp./lib/hooks/post-receive/home/git/. gitolite/hooks/common/post-receive
Sudo chown git: git/home/git/. gitolite/hooks/common/post-receive
Check application status
 
Checking status:
 
Sudo-u gitlab bundle exec rake gitlab: app: status RAILS_ENV = production
 
 
# Success will be displayed
Starting diagnostic
Config/database. yml...
Config/gitlab. yml...
/Home/git/repositories/...... exists
/Home/git/repositories/is writable ?............ YES
Remote: Counting objects: 603, done.
Remote: Compressing objects: 100% (466/466), done.
Remote: Total 603 (delta 174), reused 0 (delta 0)
Grouping objects: 100% (603/603), 53.29 KiB, done.
Resolving deltas: 100% (174/174), done.
Can clone gitolite-admin ?............ YES
UMASK for. gitolite. rc is 0007? ... YES
/Home/git/share/gitolite/hooks/common/post-receive exists? ... YES
If you got all YES-congratulations! You can go to the next step.
 
5. Start the WEB Service
Application can be started with next command:
 
# Test
Sudo-u gitlab bundle exec rails s-e production
 
# Start as a daemon
Sudo-u gitlab bundle exec rails s-e production-d
 
 
Use a management account to log on from the WEB:
 
Admin@local.host
5 iveL! Fe
6. Run the Resque process (process Job Queue ).
# Manually
Sudo-u gitlab bundle exec rake environment resque: work QUEUE = * RAILS_ENV = production BACKGROUND = yes
 
# GitLab Startup Script
Sudo-u gitlab./resque. sh
 
If you want to use Redis, you can configure this file config/resque. yml:
 
Production: redis.example.com: 6379
* OK-we have a working application now. ** But keep going-there are some things that shoshould be done *
 
 
Nginx & Unicorn
1. Unicorn
Cd/home/gitlab
Sudo-u gitlab cp config/unicorn. rb. example config/unicorn. rb
Sudo-u gitlab bundle exec unicorn_rails-c config/unicorn. rb-E production-D
 
2. Install Nginx
# Install first
Sudo apt-get install nginx
 
# Add GitLab nginx Configuration
Sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/nginx/gitlab-P/etc/nginx/sites-available/
Sudo ln-s/etc/nginx/sites-available/gitlab/etc/nginx/sites-enabled/gitlab
 
# Modify ** YOUR_SERVER_IP ** and ** YOUR_SERVER_FQDN **
# Configure your IP address and domain name
Sudo vim/etc/nginx/sites-enabled/gitlab
 
# Restart nginx:
/Etc/init. d/nginx restart
3. Init script
Create the startup script/etc/init. d/gitlab:
 
Sudo wget https://raw.github.com/gitlabhq/gitlab-recipes/master/init.d/gitlab-P/etc/init. d/
Sudo chmod + x/etc/init. d/gitlab
GitLab autostart:
 
Sudo update-rc.d gitlab defaults
You can start, restart, and stop GitLab:
Start sudo/etc/init. d/gitlab start
Restart sudo/etc/init. d/gitlab restart
Stop sudo/etc/init. d/gitlab stop

GitLab details: Click here
GitLab's: Click here

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.