Ubuntu 安装Gitlab

简介:
+关注继续查看

 
1. root权限下安装包
 
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
 
# 如果使用MySQL执行:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
 
 
2. 安装 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. 安装 Gitolite
创建 git帐号:
 
sudo adduser \
  --system \
  --shell /bin/sh \
  --gecos 'git version control' \
  --group \
  --disabled-password \
  --home /home/git \
  git
 
创建 GitLab帐号:
 
# 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 git clone -b gl-v304 https://github.com/gitlabhq/gitolite.git /home/git/gitolite
 
安装:
 
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
 
# 克隆 admin repo 添加 localhost 到 hosts
# 确保你可以访问 gitolite
sudo -u gitlab -H git clone git@localhost:gitolite-admin.git /tmp/gitolite-admin
 
# 如果成功,可以移除/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. 克隆 GitLab 代码
sudo gem install charlock_holmes --version '0.6.8'
sudo pip install pygments
sudo gem install bundler
cd /home/gitlab
 
# 获得 GitLab 代码 
sudo -H -u gitlab git 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
 
# 重命名配置文件
sudo -u gitlab cp config/gitlab.yml.example config/gitlab.yml
Select the database you want to use
 
# 使用SQLite
sudo -u gitlab cp config/database.yml.sqlite config/database.yml
 
# 或者使用MYSQL
# 使用 MySQL 需之前有安装MYSQL
 
# Login to MySQL
$ mysql -u root -p
 
# 创建 GitLab production 数据库
mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
 
# 创建MYSQL帐号  $password 改为你的密码
mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY '$password';
 
# 给这个帐号权限
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'gitlab'@'localhost';
 
# 把MYSQL密码更新到这个文件 config/database.yml
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
 
 
# 成功会显示
Starting diagnostic
config/database.yml............exists
config/gitlab.yml............exists
/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)
Receiving 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. 启动WEB服务
Application can be started with next command:
 
# 测试 
sudo -u gitlab bundle exec rails s -e production
 
# 做为守护进程启动
sudo -u gitlab bundle exec rails s -e production -d
 
 
使用管理帐号,从WEB登录:
 
admin@local.host
5iveL!fe
6. 运行Resque 进程 (处理作业队列).
# Manually
sudo -u gitlab bundle exec rake environment resque:work QUEUE=* RAILS_ENV=production BACKGROUND=yes
 
# GitLab 启动脚本
sudo -u gitlab ./resque.sh
 
如果想使用 Redis ,可以配置这个文件config/resque.yml  :
 
production: redis.example.com:6379
*Ok - we have a working application now. * *But keep going - there are some things that should be done *
 
 
Nginx && Unicorn
1. Unicorn
cd /home/gitlab/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. 安装Nginx
# Install first
sudo apt-get install nginx
 
# 添加 GitLab   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
 
# 修改 **YOUR_SERVER_IP** and **YOUR_SERVER_FQDN**
# 配置你的IP和域名
sudo vim /etc/nginx/sites-enabled/gitlab
 
# 重启 nginx:
/etc/init.d/nginx restart
3. Init 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
可以启动,重启,停止  GitLab :
启动   sudo /etc/init.d/gitlab start
重启   sudo /etc/init.d/gitlab restart
停止   sudo /etc/init.d/gitlab stop
 
 
英文版https://github.com/gitlabhq/gitlabhq/blob/stable/doc/installation.md
 
 

本文转自 ppabc  51CTO博客,原文链接:http://blog.51cto.com/ppabc/1006156
相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
网络安全 Docker 容器
gitlab 使用docker-compose代替docker安装gitlab
gitlab 使用docker-compose代替docker安装gitlab
114 0
|
4月前
|
jenkins Java Linux
第四章:安装Docker,安装配置gitlab私有仓库以及jenkins自动化部署(图文)
第四章:安装Docker,安装配置gitlab私有仓库以及jenkins自动化部署(图文)
244 1
|
4月前
|
运维 监控 开发工具
运维笔记:docker中 gitlab 安装、配置和初始化
小笔记:gitlab配置文件 /etc/gitlab/gitlab.rb 配置项
255 0
|
4月前
|
存储 应用服务中间件 开发工具
Docker安装GitLab
在Docker下安装GitLab,以及安装好之后无法访问参考8常见问题
331 0
|
6月前
|
存储 关系型数据库 应用服务中间件
gitlab是编译安装好还是yum安装好?底层原理是什么?
gitlab是编译安装好还是yum安装好?底层原理是什么?
105 0
|
8月前
|
网络安全 开发工具 数据安全/隐私保护
gitlab在服务器上的安装与配置-自己搭建一个gitlab服务器
gitlab在服务器上的安装与配置-自己搭建一个gitlab服务器
615 0
|
9月前
|
9月前
|
Ubuntu Docker 容器
Docker Compose 安装 Gitlab (基于 Ubuntu 20.04 )
Docker Compose 安装 Gitlab (基于 Ubuntu 20.04 )
207 0
|
9月前
|
Ubuntu Docker 容器
Docker 安装 Gitlab (基于 Ubuntu 20.04 )
Docker 安装 Gitlab (基于 Ubuntu 20.04 )
321 0
|
10月前
|
存储 关系型数据库 MySQL
服务器常用环境(Redmine,Gitlab,Svn,Testlink)安装及配置(四)
服务器常用环境(Redmine,Gitlab,Svn,Testlink)安装及配置(四)
服务器常用环境(Redmine,Gitlab,Svn,Testlink)安装及配置(四)
相关产品
云迁移中心
推荐文章
更多