Debian下GitLab 安装步骤详解
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-01 18:26:22 浏览: 评论:0
博客又是好久不更新了,趁着中秋假期在家学习安装了GitLab,这个折腾啊,然后写个笔记,下次可以参考.
基本上参考官方文档:https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md然后有些需要注意的地方做下记录.
一、安装要求
Debian**,MySQL,git,gitlab-shell,redis
二、安装教程
1. 首先需要确定账户可以使用sudo,并更新系统package
# run as root!,apt-get update,apt-get upgrade
apt-get install sudo #正常情况系统都带sudo命令,如果没有的话,手动安装下.
2. 安装一些必要包
sudo apt-get install -y build-essential 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 python-docutils pkg-config cmake
检查Python版本,2.5+ (3.0+还没支持)python --version,如果版本不对,请安装.
sudo apt-get install python2.7
python2 --version
sudo ln -s /usr/bin/python /usr/bin/python2
安装邮件发送支持默认即可.sudo apt-get install -y postfix
3. 安装Ruby这里我们使用taobao的镜像进行安装 可以大大的缩短下载包的时间.
- 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:请不要使用rvm来安装ruby 可能会因为环境变量导致这样那样的错误,当然如果你能解决这些问题可以使用rvm来安装ruby.
安装bundler 这里我们也使用taobao镜像来缩短下载时间,注意请使用sudo!!
sudo gem sources --remove http://rubygems.org/
sudo gem sources -a http://ruby.taobao.org/
sudo gem install bundler
4.添加Git用户
sudo adduser –disabled-login –gecos ‘GitLab’git
5.安装 GitLab-shell 新版本使用GitLab-shell来代替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/'
- # 这里修改成自己的内部域名 如: http://git.test.com/
- vim config.yml
- # Do setup
- ./bin/install
6.安装数据库m推荐MySQL,以下所有操作需要使用可以sudo的账户,代码如下:
- # 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 'gitlab'@'localhost';
7.开始安装GitLab主程序.
- ## 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.配置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
- # 这里仅需要修改host即可,
- sudo -u git -H vim config/gitlab.yml
- # Make sure GitLab can write to the log/ and tmp/ directories
- # 修改账户权限
- 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 will 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
- # 该配置文件默认即可
- sudo -u git -H vim config/puma.rb
- #如果没有puma.rb可以用下面的,二选一
- 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 is 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
- # 修改数据库账号密码, 刚才添加过gitlab这个数据库用户 直接修改成该账号即可
- sudo -u git vim config/database.yml
- #数据库密码 只需修改production即可
- # username: gitlab
- # password: "123456"
- # host: localhost
9.安装 Gems.
- cd /home/git/gitlab
- sudo gem install charlock_holmes --version '0.6.9.4'
- # 修改Bundle源地址为taobao, 首行改成 source 'http://ruby.taobao.org/'
- sudo -u git vim Gemfile
- # 这个是使用mysql数据库, 这个命令意思是排除postgres 请别搞错
- sudo -u git -H bundle install --deployment --without development test postgres aws
10.初始化数据库并启用高级功能.
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
11.安装init脚本
- 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.最后检测一下程序状态
cd gitlab
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Note:这里可能会告诉你init脚本有问题或者git版本过低, 可以无视
13.启动GitLab
sudo service gitlab start
三、Nginx配置
你可以安装nginx来代理访问GitLab 配置过程如下
1. 安装nginx:
sudo apt-get install nginx
cd /home/git/gitlab
1.增加GitLab配置文件
- 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
- # 修改配置文件 Listen 直接监听80端口即可 e.g. listen 80;
- # 修改server_name为你的内部域名 e.g. server_name git.test.com;
- sudo vim /etc/nginx/sites-available/gitlab //phpfensi.com
2.重启nginx
sudo service nginx restart
保存服务器名字的hash表是由指令 server_names_hash_max_size 和 server_names_hash_bucket_size所控制的,参数hash bucket size总是等于hash表的大小,并且是一路处理器缓存大小的倍数,如果Nginx给出需要增大 hash max size 或 hash bucket size的提示,那么首要的是增大前一个参数的大小.
vim /etc/nginx/sites-enabled/gitlab
server_names_hash_bucket_size 64;
sudo service nginx restart
这样你就可以通过nginx来访问gitlab了,默认的账户如下
用户名:admin@local.host
密码: 5iveL!fe
Tags: Debian安装 GitLab安装步骤
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)