在虚拟机中安装Gitlab
来源:互联网 发布:淘宝客服聊天用语 编辑:程序博客网 时间:2024/05/18 00:59
随着Github的盛行,social coding逐渐浮出水面,正好Gitlab刚发布了Gitlab 4.0,我今天边学习边记录安装Gitlab的过程,希望对大家有用。
1. 我是在ubuntu server 10.4上安装的,首先要准备一个VitualBox并安装ubuntu server。
2. Packages / Dependencies
这里是Gitlab的安装说明:
https://github.com/gitlabhq/gitlabhq/blob/stable/doc/install/installation.md
我们先更新和安装Gitlab必须的依赖,以下操作请保持网络畅通:
# run as root
sudo apt-get update //
会有些更新失败,不必管它
sudo apt-get upgrade //
这个比较慢,可以去喝杯茶
# Install vim
sudo apt-get install -y vim
Install the required packages: // 下面这句比较长,不要打错了
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev wget curl git-core openssh-server redis-server postfix checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev
# Install Python
sudo apt-get install python
# Make sure that Python is 2.5+ (3.x is not supported at the moment)
python –version //
我装上的版本是
python 2.7.3
# If it's Python 3 you might need to install Python 2 separately
sudo apt-get install python2.7
# Make sure you can access Python via python2
python2 --version
# If you get a "command not found" error create a link to the python binary
sudo ln -s /usr/bin/python /usr/bin/python2 //
我的
python2
似乎已经存在了,不管它
2. 安装Ruby
mkdir /tmp/ruby && cd /tmp/ruby //
建个临时目录下载
ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz //
下载并解压
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure // configure & make
有些慢,耐心等下
make
sudo make install
Install the Bundler Gem:
sudo gem install bundler
3. 创建gitlab用户
//
创建
Git
账户
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
Git
//
创建
Gitlab
账户
,
并禁止登录
sudo adduser --disabled-login --gecos 'GitLab' gitlab
# Add it to the git group
sudo usermod -a -G git gitlab
# Generate the SSH key //
一定是用
gitlab
用户生成
id_rsa
sudo -u gitlab -H ssh-keygen -q -N '' -t rsa -f /home/gitlab/.ssh/id_rsa
4. Gitolite
克隆Gitolite并安装:
//
以下所有操作要在
git
用户下操作,所有命令前加
”sudo –u git”
cd /home/git
sudo -u git -H git clone -b gl-v320 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
# Add Gitolite scripts to $PATH
sudo -u git -H mkdir /home/git/bin
sudo -u git -H sh -c 'printf "%b\n%b\n" "PATH=\$PATH:/home/git/bin" "export PATH" >> /home/git/.profile'
sudo -u git -H sh -c 'gitolite/install -ln /home/git/bin'
# Copy the gitlab user's (public) SSH key ...
sudo cp /home/gitlab/.ssh/id_rsa.pub /home/git/gitlab.pub
sudo chmod 0444 /home/git/gitlab.pub
# ... and use it as the admin key for the Gitolite setup
sudo -u git -H sh -c "PATH=/home/git/bin:$PATH; gitolite setup -pk /home/git/gitlab.pub"
Fix the directory permissions for theconfiguration directory:
# Make sure the Gitolite config dir is owned by git
sudo chmod 750 /home/git/.gitolite/
sudo chown -R git:git /home/git/.gitolite/
Fixthe directory permissions for the repositories:
# Make sure the repositories dir is owned by git and it stays that way
sudo chmod -R ug+rwXs,o-rwx /home/git/repositories/
sudo chown -R git:git /home/git/repositories/
测试下git是否可以clone
# Clone the admin repo so SSH adds localhost to known_hosts ...
# ... and to be sure your users have access to Gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
# If it succeeded without errors you can remove the cloned repo
sudo rm -rf /tmp/gitolite-admin
到这里,基本算完成一半了。
安装数据库
Gitlab 4.0 支持PostgreSQL,我们用PostgreSQL:
# Install the database packages
sudo apt-get install -y postgresql-9.1 libpq-dev
# Login to PostgreSQL
sudo -u postgres psql -d template1
# Create a user for GitLab. (change $password to a real password)
template1=# CREATE USER gitlab WITH PASSWORD '$password';
# Create the GitLab production database & grant all privileges on database
template1=# CREATE DATABASE gitlabhq_production OWNER gitlab;
# Quit the database session
template1=# \q
# Try connecting to the new database with the new user
sudo -u gitlab -H psql -d gitlabhq_production
安装Gitlab
# We'll install GitLab into home directory of the user "gitlab"
cd /home/gitlab
# Clone GitLab repository
sudo -u gitlab -H git clone https://github.com/gitlabhq/gitlabhq.git gitlab
# Go to gitlab dir
cd /home/gitlab/gitlab
# Checkout to stable release
sudo -u gitlab -H git checkout 4-0-stable
Configure it
cd /home/gitlab/gitlab
# Copy the example GitLab config
sudo -u gitlab -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
sudo -u gitlab -H vim config/gitlab.yml
# Make sure GitLab can write to the log/ and tmp/ directories
sudo chown -R gitlab log/
sudo chown -R gitlab tmp/
sudo chmod -R u+rwX log/
sudo chmod -R u+rwX tmp/
# Copy the example Unicorn config
sudo -u gitlab -H cp config/unicorn.rb.example config/unicorn.rb
Configure GitLab DB settings
#
我们用的是
PostgreSQL
,所以使用
postgresql
模板
sudo -u gitlab cp config/database.yml.postgresql config/database.yml
#
记得修改
database.yml
里的
username
为“
gitlab”
,密码为空
sudo –u gitlab vi config/database.yml
Install Gems
cd /home/gitlab/gitlab
sudo gem install charlock_holmes --version '0.6.9'
//
安装需要几分钟时间
sudo -u gitlab -H bundle install --deployment --without development test mysql
Configure Git
sudo -u gitlab -H git config --global user.name "GitLab"
sudo -u gitlab -H git config --global user.email "gitlab@localhost"
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
Initialise Database and Activate Advanced Features
sudo -u gitlab -H bundle exec rake gitlab:app:setup RAILS_ENV=production
Install Init Script
Downloadthe init script (will be /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
MakeGitLab start on boot:
sudo update-rc.d gitlab defaults 21
//
重启系统后并测试
# reboot
sudo -u gitlab -H bundle exec rake gitlab:check RAILS_ENV=production
如果你也像下图一样,说明一切顺利:
Nginx
最后一步,配置Nginx web service:
sudo apt-get install nginx
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
# Change **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
# to the IP address and fully-qualified domain name
# of your host serving GitLab
sudo vim /etc/nginx/sites-enabled/gitlab
// 稳妥些,重新系统
reboot
系统重启后,直接输入你虚拟机的http://IP地址,It’s works!!
不要忘了,初始用户密码是:
admin@local.host
5iveL!fe
Good luck!
- 在虚拟机中安装Gitlab
- 虚拟机ubuntu安装gitlab
- 虚拟机Ubuntu上安装gitlab
- ubuntu中gitlab安装
- 在centos6.5中安装 GitLab 全过程和问题记录
- 在虚拟机中安装windows
- 在虚拟机中安装CentOS7
- 在虚拟机中安装Ubuntu
- 在虚拟机中安装CentOS7
- 在虚拟机中安装 Ubuntu
- 在虚拟机中安装Win10
- 在CentOS上安装GITLAB
- 在Ubuntu上安装GitLab
- Bitnami提供Gitlab虚拟机中ssh开启
- Bitnami提供Gitlab虚拟机中ssh开启
- 在Docker中部署GitLab
- 在VPC 2007中安装虚拟机操作系统
- 在linux虚拟机中安装VMwareTools
- linux时间管理
- hadoop distcp 命令
- 找工作得失
- ASP.NET简单实现图片防盗链
- 《编程之美》——读书笔记
- 在虚拟机中安装Gitlab
- spring 事务配置方式
- Rookie零基础学java(二)第一个java程序HelloWorld(在win7和linux下)
- 代码大全 第十章 读书笔记(1)
- 编译内核 mkimage" command not found - U-Boot images will not be buil
- LCD设备驱动程序3
- 图片操作旋转等
- php将图片直接写入SQLServer2008
- Java 人才