设为首页 收藏本站
查看: 991|回复: 0

[经验分享] gitlab部署

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-11-4 08:54:36 | 显示全部楼层 |阅读模式
一、配置epel源
1
2
wget   http://mirrors.aliyun.com/epel/6 ... ease-6-8.noarch.rpm
rpm  -ivh  epel-release-6-8.noarch.rpm




二、安装依赖包
1
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
下载链接:
1
wget -O git-src.zip https://github.com/git/git/archive/master.zip




1
2
3
4
5
[iyunv@localhost ~]# unzip git-src.zip
[iyunv@localhost ~]# cd git-master/
[iyunv@localhost git-master]# make prefix=/usr/local all
[iyunv@localhost git-master]# make prefix=/usr/local install
[iyunv@localhost git-master]# ln -fs /usr/local/bin/git* /usr/bin/




四、安装ruby
1
2
3
4
5
6
7
8
[iyunv@localhost src]# wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-2.1.5.tar.gz
[iyunv@localhost src]# tar-zxf ruby-2.1.5.tar.gz
[iyunv@localhost src]# cd ruby-2.1.5
[iyunv@localhost ruby-2.1.5]# ./configure --disable-install-rdoc && make && make install
[iyunv@localhost ~]# ln -s /usr/local/bin/ruby /usr/bin/ruby
[iyunv@localhost ~]# ln -s /usr/local/bin/gem /usr/bin/gem
[iyunv@localhost ~]# gem install bundler --no-ri --no-rdoc
[iyunv@localhost ~]# ln -s /usr/local/bin/bundle /usr/bin/bundle




五、安装mysql并初始化gitlab库
1
2
3
4
5
6
[iyunv@localhost ~]# yum -y install mysql mysql-devel mysql-server
[iyunv@localhost ~]# service mysqld start
[iyunv@localhost ~]# chkconfig mysqld on
[iyunv@localhost ~]# mysql
mysql> create database gitlab;
mysql> grant all privileges on gitlab.* to 'gitlab'@'localhost' identified by 'gitlab';





测试是否可以用gitlab登录数据库:
1
2
[iyunv@localhost ~]# mysql -u gitlab -p -D gitlab
Enter password:





六、安装redis
1
2
3
4
5
6
[iyunv@localhost ~]# yum -y install redis
[iyunv@localhost ~]# vi /etc/redis.conf
  36 unixsocket /tmp/redis.sock
37 unixsocket perm 755
[iyunv@localhost ~]# service redis start
[iyunv@localhost ~]# chkconfig redis on




七、创建git用户并允许sudo
1
2
[iyunv@localhost ~]# useradd git
echo "git ALL=(ALL)       NOPASSWD: ALL" >> /etc/sudoers




八、安装gitlab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[iyunv@localhost ~]# cd /home/git/
[iyunv@localhost git]# sudo -u git -H git clone   -b 7-8-stable gitlab
[iyunv@localhost git]# cd gitlab
[iyunv@localhost gitlab]# cp config/gitlab.yml.example config/gitlab.yml
[iyunv@localhost gitlab]# vi config/gitlab.yml
  20     host: localhost
  21     port: 80
  267    bin_path: /usr/bin/git
[iyunv@localhost gitlab]# chown -R git log/
[iyunv@localhost gitlab]# chown -R git tmp/
[iyunv@localhost gitlab]# chmod -R u+rwX log/
[iyunv@localhost gitlab]# chmod -R u+rwX tmp/
[iyunv@localhost gitlab]# sudo -u git -H mkdir /home/git/gitlab-satellites
[iyunv@localhost gitlab]# sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites
[iyunv@localhost gitlab]# chmod -R u+rwX tmp/pids/
[iyunv@localhost gitlab]# chmod -R u+rwX tmp/sockets
[iyunv@localhost gitlab]# chmod -R u+rwX public/uploads/
[iyunv@localhost gitlab]# cp config/unicorn.rb.example  config/unicorn.rb
[iyunv@localhost gitlab]# cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb




以上不存在的目录,手动创建。
配置数据库:
1
2
3
4
5
6
[iyunv@localhost gitlab]# cp config/database.yml.mysql config/database.yml
[iyunv@localhost gitlab]# vi config/database.yml
  9  database: gitlab       #这里的数据库要跟在mysql中创建的库名一致。
10  pool: 10
11  username: gitlab
12  password: gitlab




九、安装gitlab-shell
1
2
3
4
5
6
7
8
[iyunv@localhost ~]# cd /home/git/
[iyunv@localhost git]# sudo -u git -H git clone   -b v2.6.0
[iyunv@localhost git]# cd gitlab-shell/
[iyunv@localhost gitlab-shell]# cp config.yml.example config.yml
[iyunv@localhost gitlab-shell]# vi config.yml
  9      gitlab_url: http://localhost:8080/
  30   bin: /usr/bin/redis-cli
[iyunv@localhostgitlab-shell]# sudo -u git -H ./bin/install




十、nginx安装
1
2
3
4
5
6
7
[iyunv@localhost src]# tar -zxf pcre-8.38.tar.gz
[iyunv@localhost src]# cd pcre-8.38
[iyunv@localhostp cre-8.38]# ./configure --prefix=/usr/local/pcre-8.38 && make && make install
[iyunv@localhost src]# wget http://124.205.69.171/files/8095 ... /nginx-1.8.1.tar.gz
[iyunv@localhost src]# tar -zxf nginx-1.8.1.tar.gz
[iyunv@localhost src]# cd nginx-1.8.1
[iyunv@localhost 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
1
2
[iyunv@localhost ~]# cd /home/git/gitlab
[iyunv@localhost gitlab]# sudo -u git -H bundle install --deployment --without development testpostgres aws




十二、初始化数据库
1
[iyunv@localhost gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production




十三、拷贝启动文件脚本及日志切割文件
1
2
3
[iyunv@localhost gitlab]# cp lib/support/init.d/gitlab /etc/init.d/gitlab
[iyunv@localhost gitlab]# cp lib/support/init.d/gitlab.default.example /etc/default/gitlab
[iyunv@localhost gitlab]# cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab




十四、设置git账号信息
1
2
3
[iyunv@localhost gitlab]# sudo -u git -H "/usr/bin/git" config --global user.name  "GitLab"
[iyunv@localhost gitlab]# sudo -u git -H "/usr/bin/git" config --global user.email "example@example.com"
[iyunv@localhost gitlab]# sudo -u git -H "/usr/bin/git" config --global core.autocrlf "input"




十五、配置nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[iyunv@localhost ~]# 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;
        }

}
[iyunv@localhost ~]# mkdir -p /var/log/nginx
[iyunv@localhost ~]# chown -R git:git/var/log/nginx/
[iyunv@localhost ~]# chown -R git:git /usr/local/nginx/
[iyunv@localhost ~]# /usr/local/nginx/sbin/nginx -t
[iyunv@localhost gitlab]# service nginx restart




十六、检测当前环境
1
[iyunv@localhostgitlab]# sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production




可能会有报错:Error: Table 'gitlab.projects' doesn't exist
这时重新初始化数据库,执行以下命令:
1
[iyunv@localhost gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production




会发现,执行结束时生成了一个登录账号和密码:
1
2
login.........root
password......5iveL!fe 用来登录gitlab




再次执行环境检测命令……OK
十七、拉取gitlab静态资源文件
1
[iyunv@localhost gitlab]# sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production




十八、启动gitlab
1
2
3
4
[iyunv@localhost gitlab]# /etc/init.d/gitlab start
[iyunv@localhost gitlab]# sudo chmod -R ug+rwX,o-rwx /home/git/repositories/
[iyunv@localhost gitlab]# sudo chmod -R ug-s /home/git/repositories/
[iyunv@localhost gitlab]# find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s




十九、检测各个组件是否正常工作
1
[iyunv@localhost 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
1
2
[iyunv@localhost 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
1
2
[iyunv@localhost ~]# vi/usr/local/nginx/conf/nginx.conf
  2 user git;



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-295550-1-1.html 上篇帖子: 部署gitblit服务器 下篇帖子: Git常见相关知识与命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表