【Linux进阶】CentOS安装GitLab
来源:互联网 发布:2016年中国零售业数据 编辑:程序博客网 时间:2024/05/17 16:13
前言
GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目。它拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释。可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库。团队成员可以利用内置的简单聊天程序(Wall)进行交流。它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找。GitLab在线
准备
环境
yum源
为了提高软件安装速度,将yum源设置为阿里云开源镜像(阿里云服务器请使用默认源)
$ cd /etc/yum.repos.d$ wget -OCentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
安装必要软件包
$ yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
安装Git
// 查看当前git版本$ git --version// 如果小于1.7.10则先卸载$ yum remove git// 下载最新的git并安装$ wget -O git-src.zip https://github.com/git/git/archive/master.zip$ unzip git-src.zip$ cd git-src$ make prefix=/usr/local all$ make prefix=/usr/local install$ ln -fs /usr/local/bin/git* /usr/bin/
安装Ruby环境
$ mkdir /tmp/ruby && cd /tmp/ruby$ curl --progress ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz | tar xz//可自行下载ruby包解压安装https://ruby.taobao.org/$ cd ruby-2.1.5//此处最好指定OpenSSL目录//./configure --with-openssl-dir=/usr/bin/openssl 可以使用rmp -ql openssl查看$ ./configure --disable-install-rdoc$ make && make install$ ln -s /usr/local/bin/ruby /usr/bin/ruby$ ln -s /usr/local/bin/gem /usr/bin/gem$ ln -s /usr/local/bin/bundle /usr/bin/bundle// 设置ruby gem源为淘宝$ gem source -r https://rubygems.org/$ gem source -a https://ruby.taobao.org/$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/$ gem sources -l*** CURRENT SOURCES ***https://ruby.taobao.org# 请确保只有 ruby.taobao.org$ gem install bundler --no-ri --no-rdoc
安装MySQL及初始化GitLab库
$ yum install mysql mysql-devel mysql-server -y$ /etc/init.d/mysqld start$ chkconfig mysqld on// 登录mysql创建gitab的帐号和数据库mysql> CREATE USER 'gitlab'@'localhost' IDENTIFIED BY'gitlab';mysql> CREATE DATABASE IFNOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO'gitlab'@'localhost';//测试是否可以用git帐号登录数据库sudo -u gitlab'@'localhost -H mysql -u gitlab -p -D gitlabhq_production
安装Redis
$ yum -y install redis$ /etc/init.d/redis start$ chkconfig redis on
添加git帐号并允许sudo
$ useradd --comment 'GitLab' git$ echo "git ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
安装GitLab
$ /home/git$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-8-stable gitlab$ cd /home/git/gitlab$ sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml// 编辑git路径, gitlab的host:port$ vim config/gitlab.yml// bin_path: /usr/local/bin/git// host: localhost// port: 80 // 给文件夹添加相应的权限$ chown -R git log/$ chown -R git tmp/$ chmod -R u+rwX log/$ chmod -R u+rwX tmp/// 创建必要的文件夹,以及复制配置文件$ sudo -u git -H mkdir /home/git/gitlab-satellites$ 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/$ sudo -u git -H mkdir public/uploads$ sudo chmod -R u+rwX public/uploads$ 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.mysql config/database.yml$ sudo -u git -H vim config/database.yml$ vim config/database.yml// production:// username: gitlab// password: "gitlab"
安装GitLab-Shell
$ cd /home/git$ sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-shell.git -b v2.6.0$ cd gitlab-shell/$ sudo -u git -H cp config.yml.example config.yml//将gitlab_url设置为ip或者domain// 编辑配置文件, 设置gitlab_url, redis-cli, log-level...$ vim config.yml// gitlab_url: "http://localhost/"// /usr/bin/redis-cli// 安装git-shell$ sudo -u git -H ./bin/install
安装需要ruby的gems
$ cd /home/git/gitlab$ sudo -u git -H bundle install --deployment --without development test postgres aws//如果此时仍然使用的是原始Gem源进行安装的话,找到所有的Gemfile文件并将ruby源换为淘宝源//安装注意看ERROR信息,如果缺少依赖,需要手动安装//yum -y install cmake 和 yum -y install mysql-devel
初始化数据库(创建GitLab相关表)
$ sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
安装启动文件以及日志切割文件
cp lib/support/init.d/gitlab /etc/init.d/gitlabcp lib/support/init.d/gitlab.default.example /etc/default/gitlabcp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
设置git帐号信息
$ sudo -u git -H git config --global user.name "Troy Zhang"$ sudo -u git -H git config --global user.email "troyz@synnex.com"$ sudo -u git -H git config --global core.autocrlf input
安装Nginx
$ yum -y install nginx$ vim /etc/nginx/nginx.confuser root git;worker_processes 2;pid /var/run/nginx.pid;events { worker_connections 1024;}http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';# GITLAB# Maintainer: @randx# App Version: 5.0upstream gitlab { server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;}server { listen *:80 default_server; # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea server_name YOUR_SERVER_FQDN; # e.g., server_name source.example.com; server_tokens off; # don't show the version number, a security best practice root /home/git/gitlab/public; # Set value of client_max_body_size to at least the value of git.max_size in gitlab.yml client_max_body_size 5m; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files from defined root folder;.# @gitlab is a named location for the upstream fallback, see below try_files $uri $uri/index.html $uri.html @gitlab; } # if a file, which is not found in the root folder is requested,# then the proxy pass the request to the upsteam (gitlab unicorn) location @gitlab { proxy_read_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_connect_timeout 300; # https://github.com/gitlabhq/gitlabhq/issues/694 proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://gitlab; }}}
更改权限,启动nginx
$ nginx -t$ chown -Rgit:git /var/lib/nginx/$ /etc/init.d/nginx start
检测当前环境
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
拉取gitlab静态资源文件
$ sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production
启动gitlab
$ /etc/init.d/gitlab start
检测各个组件是否正常工作
$ sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
0 0
- 【Linux进阶】CentOS安装GitLab
- linux安装gitlab(CentOS)
- Centos安装gitlab安装
- CentOS 6安装Gitlab
- CentOS下一键安装GitLab
- CentOS上安装gitlab
- CentOS上安装GitLab
- centOS 7安装 gitLab
- Centos 安装gitlab
- centos下安装gitlab
- CentOS安装GitLab
- CentOS 7 安装 Gitlab
- CentOS安装GitLab
- Centos下安装GitLab
- Centos 7 安装 GitLab
- CentOS 7 安装GitLab
- centos安装gitlab-ce
- centos 7 安装gitlab
- cdm ldm pdm 区别、转化
- Notification使用详解之一:基础应用
- hash_map中string为key的解决方法
- Service的一点心得
- 用Fragment解决屏幕旋转(状态发生变化)状态不能保持的问题
- 【Linux进阶】CentOS安装GitLab
- winApplication与winConsoleApplication
- Difference between frame and bounds? frame和bounds有什么不同?
- adb命令查看sharedpreferences
- 从JDK源码角度看并发锁的优化
- 自定义的HorizontalScrollView与Viewpager组成tab之间的滑动
- 将对象转换成字典
- Android学习笔记二十九:Android Socket编程介绍(示例,出错代码)
- iOS学习之——状态栏