gitlab部署

一、配置epel源

wget   http://mirrors.aliyun.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm  -ivh  epel-release-6-8.noarch.rpm

二、安装依赖包

yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make cmake 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

下载链接:

wget -O git-src.zip https://github.com/git/git/archive/master.zip

[[email protected] ~]# unzip git-src.zip
[[email protected] ~]# cd git-master/
[[email protected] git-master]# make prefix=/usr/local all
[[email protected] git-master]# make prefix=/usr/local install
[[email protected] git-master]# ln -fs /usr/local/bin/git* /usr/bin/

四、安装ruby

[[email protected] src]# wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz
[[email protected] src]# tar-zxf ruby-2.1.5.tar.gz
[[email protected] src]# cd ruby-2.1.5
[[email protected] ruby-2.1.5]# ./configure --disable-install-rdoc && make && make install
[[email protected] ~]# ln -s /usr/local/bin/ruby /usr/bin/ruby
[[email protected] ~]# ln -s /usr/local/bin/gem /usr/bin/gem
[[email protected] ~]# gem install bundler --no-ri --no-rdoc
[[email protected] ~]# ln -s /usr/local/bin/bundle /usr/bin/bundle

五、安装mysql并初始化gitlab库

[[email protected] ~]# yum -y install mysql mysql-devel mysql-server
[[email protected] ~]# service mysqld start
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# mysql
mysql> create database gitlab;
mysql> grant all privileges on gitlab.* to ‘gitlab‘@‘localhost‘ identified by ‘gitlab‘;

测试是否可以用gitlab登录数据库:

[[email protected] ~]# mysql -u gitlab -p -D gitlab
Enter password:

六、安装redis

[[email protected] ~]# yum -y install redis
[[email protected] ~]# vi /etc/redis.conf
  36 unixsocket /tmp/redis.sock
 37 unixsocket perm 755
[[email protected] ~]# service redis start
[[email protected] ~]# chkconfig redis on

七、创建git用户并允许sudo

[[email protected] ~]# useradd git
echo "git ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers

八、安装gitlab

[[email protected] ~]# cd /home/git/
[[email protected] git]# sudo -u git -H git clone   -b 7-8-stable gitlab
[[email protected] git]# cd gitlab
[[email protected] gitlab]# cp config/gitlab.yml.example config/gitlab.yml
[[email protected] gitlab]# vi config/gitlab.yml
  20     host: localhost
  21     port: 80
  267    bin_path: /usr/bin/git
[[email protected] gitlab]# chown -R git log/
[[email protected] gitlab]# chown -R git tmp/
[[email protected] gitlab]# chmod -R u+rwX log/
[[email protected] gitlab]# chmod -R u+rwX tmp/
[[email protected] gitlab]# sudo -u git -H mkdir /home/git/gitlab-satellites
[[email protected] gitlab]# sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
[[email protected] gitlab]# chmod -R u+rwX tmp/pids/
[[email protected] gitlab]# chmod -R u+rwX tmp/sockets
[[email protected] gitlab]# chmod -R u+rwX public/uploads/
[[email protected] gitlab]# cp config/unicorn.rb.example  config/unicorn.rb
[[email protected] gitlab]# cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

以上不存在的目录,手动创建。

配置数据库:

[[email protected] gitlab]# cp config/database.yml.mysql config/database.yml
[[email protected] gitlab]# vi config/database.yml
  9  database: gitlab       #这里的数据库要跟在mysql中创建的库名一致。
 10  pool: 10
 11  username: gitlab
 12  password: gitlab

九、安装gitlab-shell

[[email protected] ~]# cd /home/git/
[[email protected] git]# sudo -u git -H git clone   -b v2.6.0
[[email protected] git]# cd gitlab-shell/
[[email protected] gitlab-shell]# cp config.yml.example config.yml
[[email protected] gitlab-shell]# vi config.yml
  9      gitlab_url: http://localhost:8080/
  30   bin: /usr/bin/redis-cli
[[email protected]]# sudo -u git -H ./bin/install

十、nginx安装

[[email protected] src]# tar -zxf pcre-8.38.tar.gz
[[email protected] src]# cd pcre-8.38
[[email protected] cre-8.38]# ./configure --prefix=/usr/local/pcre-8.38 && make && make install
[[email protected] src]# wget http://124.205.69.171/files/8095000002FE839E/nginx.org/download/nginx-1.8.1.tar.gz
[[email protected] src]# tar -zxf nginx-1.8.1.tar.gz
[[email protected] src]# cd nginx-1.8.1
[[email protected] nginx-1.8.1]# ./configure  --prefix=/usr/local/nginx --user=git  --group=git--with-http_ssl_module  --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.38/  && make  && make install

十一、安装需要的gems

[[email protected] ~]# cd /home/git/gitlab
[[email protected] gitlab]# sudo -u git -H bundle install --deployment --without development testpostgres aws

十二、初始化数据库

[[email protected] gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

十三、拷贝启动文件脚本及日志切割文件

[[email protected] gitlab]# cp lib/support/init.d/gitlab /etc/init.d/gitlab
[[email protected] gitlab]# cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
[[email protected] gitlab]# cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

十四、设置git账号信息

[[email protected] gitlab]# sudo -u git -H "/usr/bin/git" config --global user.name  "GitLab"
[[email protected] gitlab]# sudo -u git -H "/usr/bin/git" config --global user.email "[email protected]"
[[email protected] gitlab]# sudo -u git -H "/usr/bin/git" config --global core.autocrlf "input"

十五、配置nginx

[[email protected] ~]# vi /usr/local/nginx/conf/nginx.conf
    upstream gitlab {
        server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
    }
    server {
        listen       80;
        server_name  localhost;
 
        access_log  /var/log/nginx/gitlab_access.log;
        error_log   /var/log/nginx/gitlab_error.log;
 
        root  /home/git/gitlab/public;
 
        location / {
            try_files $uri $uri/index.html $uri.html @gitlab;
        }
 
        location @gitlab {
            proxy_read_timeout 300;
            proxy_connect_timeout 300;
            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;
        }
 
}
[[email protected] ~]# mkdir -p /var/log/nginx
[[email protected] ~]# chown -R git:git/var/log/nginx/
[[email protected] ~]# chown -R git:git /usr/local/nginx/
[[email protected] ~]# /usr/local/nginx/sbin/nginx -t
[[email protected] gitlab]# service nginx restart

十六、检测当前环境

[[email protected]]# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

可能会有报错:Error: Table ‘gitlab.projects‘ doesn‘t exist

这时重新初始化数据库,执行以下命令:

[[email protected] gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

会发现,执行结束时生成了一个登录账号和密码:

login.........root
password......5iveL!fe 用来登录gitlab

再次执行环境检测命令……OK

十七、拉取gitlab静态资源文件

[[email protected] gitlab]# sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

十八、启动gitlab

[[email protected] gitlab]# /etc/init.d/gitlab start
[[email protected] gitlab]# sudo chmod -R ug+rwX,o-rwx /home/git/repositories/
[[email protected] gitlab]# sudo chmod -R ug-s /home/git/repositories/
[[email protected] gitlab]# find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s

十九、检测各个组件是否正常工作

[[email protected] gitlab]#sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

错误一:Send ping to redisserver: Could not connect to Redis at /tmp/redis.sock: Permission denied

[[email protected] gitlab]#vi /home/git/gitlab-shell/config.yml
35   #socket: /tmp/redis.sock # Comment out thisline if you want to use TCP

错误二:用浏览器访问时,出现“502 Bad Gateway”

编译nginx时指定 --user=git --group=git

[[email protected] ~]# vi/usr/local/nginx/conf/nginx.conf
  2 user git;
时间: 2024-08-06 16:04:36

gitlab部署的相关文章

gitlab部署迁移升级

一.gitlab部署 1.参考网站 https://about.gitlab.com/downloads/#centos6 2.部署步骤: 2.1. Install and configure the necessary dependencies sudo yum install curl openssh-server openssh-clients postfix cronie sudo service postfix start sudo chkconfig postfix on sudo 

gitlab部署、配置更改、备份及恢复

1.gitlab部署 官网 gitlab.com Ubuntu14.04安装 1.Install and configure the necessary dependencies sudoapt-get install postfix 2. Download the Omnibus package and install everything wgethttps://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.9.4-omn

持续集成与自动化部署 - gitlab部署 (四)

1 gitlab部署 部署gitlab参考链接 GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目. GitLab拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释.可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库.它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找. 1.基础环境准备 [[email protected] ~]# yum

GitLab 部署及管理员账号初始化

至于GitLab 部署网上已有大篇幅的资料,但个人都是试了很久才成功的,以此篇博客记录下来,方便自己提心别人 环境:centos 7 gitlab version: 1.cd /home 1.下载rpm安装包 :https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.8.5-ce.1.el7.x86_64.rpm 2.切换到gitlab-ce-8.8.5-ce.1.el7.x86_64.rpm所在目录执行 :rpm -

centos7.4+GitLab部署

GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务.系统环境准备建议:内存4G以上不然带不动 [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) [[email protected] ~]# uname -r 3.10.0-693.el7.x86_64 #关闭firewalld和NetWorkManager [[email 

Gitlab部署及基础配置

Gitlab安装 基础包安装 yum install -y curl policycoreutils-python openssh-server systemctl enable sshd systemctl start sshd firewall-cmd --permanent --add-service=http systemctl reload firewalld 安装 postfix yum install postfix systemctl enable postfix systemc

私有gitlab部署

1.官网 https://about.gitlab.com/ https://www.sourcetreeapp.com/ 2.安装gitlab yum install curl openssh-server openssh-clients postfix cronie rpm -ivh gitlab-ce-7.12.2~conibus......rpm gitlab-ctl reconfigure/etc/init.d/postfix startchkconfig postfix on 4.查

Docker学习——gitlab部署

Gitlab 下载镜像 docker pull hub.c.163.com/gutenye/gitlab-ce:latest 查看镜像 docker images 启动容器 宿主机和docker的端口映射关系 宿主机    docker虚拟机 80    32797 22    32798 443    32796 docker run -d -p 80:32797 -p 22:32798 -p 443:32796 --name gitlab hub.c.163.com/gutenye/gitl

Gitlab部署及汉化操作

一.简介 GitLab是一个利用 Ruby on Rails 开发的开源应用程序,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目. GitLab拥有与Github类似的功能,能够浏览源代码,管理缺陷和注释.可以管理团队对仓库的访问,它非常易于浏览提交过的版本并提供一个文件历史库.它还提供一个代码片段收集功能可以轻松实现代码复用,便于日后有需要的时候进行查找. 二.基础环境准备 2.1 安装依赖包 如想使用Postfix来发送邮件,在安装期间请选择'Internet S