如何安装和配置在Ubuntu 14.04 gitlab

0、安装准备

gitlab提供。deb包里面包含gitlab社区版和它的依赖性(Ruby, PostgreSQL, Redis, Nginx, Unicorn and other gems)已经编译。安装此包很简单。但由于它将安装自己的软件包的依赖关系(nginx,PostgreSQL,等)

系统使用了Ubuntu 14.04,假如的你域名为git.example.com 并且已经安装ruby,git server

本文使用的是非root权限 需要使用sudo 进行管理

    0.1、更新系统

            

sudo apt-get update
sudo apt-get upgrade
    0.2、为GitLab创建一个git用户
sudo adduser --disabled-login --gecos 'GitLab' git
    0.3、插入系统依赖的包
sudo apt-get install build-essential cmake zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate
    0.4、安装git、postfix(邮件服务器可选)
sudo apt-get install git postfix
    0.5、安装postgresql数据库等工具类、创建gitlab的生产库
sudo apt-get install postgresql postgresql-client libpq-dev
sudo -u postgres createuser --createdb git
sudo -u postgres createdb --owner=git gitlabhq_production
    0.6、检测生产库是否安装
sudo -u git -H psql -d gitlabhq_production -c "SELECT VERSION()

1、安装gitlab(使用源码安装)

    1.1、创建git目录、clone
mkdir /home/git && cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 6-9-stable gitlab
cd gitlab
    1.2、配置gitlab.conf
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
sudo nano config/gitlab.yml
    1.3、编辑gitlab.yml
vim /home/git/gitlab/config/gitlab.yml
###################################
production: &base
  gitlab:
    host: git.example.com 
    port: 80
    https: false
    ...
    email_from: gitlab@example.com
    ...
    support_email: support@example.com
###################################
    1.4、授予权限给git,创建git存储目录
sudo chown -R git {log,tmp}
sudo chmod -R u+rwX {log,tmp,tmp/pids,tmp/sockets,public/uploads}
sudo -u git -H mkdir /home/git/gitlab-satellites
sudo chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
    1.5、创建Unicorn, Rack attack, and PostgreSQL的配置文件
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
sudo -u git cp config/database.yml.postgresql config/database.yml
sudo -u git -H chmod o-rwx config/database.yml
    1.6、安装gems、gitlab-shell
sudo gem install bundler
sudo -u git -H bundle install --deployment --without development test mysql aws
sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.4] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
    1.7、配置如下   vim /home/git/gitlab-shell/config.yml
user: git
gitlab_url: http://git.example.com/
http_settings:
  self_signed_cert: false
repos_path: "/home/git/repositories/"
auth_file: "/home/git/.ssh/authorized_keys"
redis:
  bin: "/usr/bin/redis-cli"
  host: localhost
  port: 6379
  namespace: resque:gitlab
log_level: INFO
audit_usernames: false
    1.8、数据库初始化
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo update-rc.d gitlab defaults 21
sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
    1.9、检测应用状态
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

    显示如下信息 表示系统正常

System information
System:Ubuntu 14.04
Current User:git
Using RVM:no
Ruby Version:2.1.2p95
Gem Version:2.2.2
Bundler Version:1.10.6
Rake Version:10.3.1
Sidekiq Version:2.17.0
GitLab information
Version:6.9.2
Revision:e46b644
Directory:/home/git/gitlab
DB Adapter:postgresql
URL:http://git.3nchina.cn
HTTP Clone URL:http://git.3nchina.cn/some-project.git
SSH Clone URL:ssh://git@git.3nchina.cn:2203/some-project.git
Using LDAP:no
Using Omniauth:no
GitLab Shell
Version:1.9.4
Repositories:/home/git/repositories/
Hooks:/home/git/gitlab-shell/hooks/
Git:/usr/bin/git

2、配置生产环境、git用户信息

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@example.com"
sudo -u git -H git config --global core.autocrlf input

3、启动、停止、重启gitlab

sudo service gitlab start
sudo service gitlab stop
sudo service gitlab restart

4、集成nginx 

sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo vim /etc/nginx/sites-available/gitlab

#eg
listen 80;
server_name git.example.com;
server_tokens off; 
root /home/git/gitlab/public;
    4.1、重启nginx 
 sudo rm /etc/nginx/sites-enabled/default
 sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
 sudo service nginx restart

5、检测gitlab是否正常

 cd /home/git/gitlab
 sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

https://www.linode.com/docs/applications/development/how-to-install-and-configure-gitlab-on-ubuntu-14-04-trusty-tahr

转载于:https://my.oschina.net/u/923974/blog/529186

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值