博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gitLab的安装
阅读量:3746 次
发布时间:2019-05-22

本文共 4795 字,大约阅读时间需要 15 分钟。

注意,以下一到五步骤都需要用root用户操作

一:初始化安装环境

yum -ygroupinstall 'Development Tools'

yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-develtcl-devel openssl-devel curl-devel expat-devel db4-devel byaccsqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2libxml2-devel libxslt libxslt-devel libicu libicu-develsystem-config-firewall-tui crontabs logwatch logrotateperl-Time-HiRescmakelibcom_err-devel.i686 libcom_err-devel.x86_64 zlib-devel perl-CPANgettext gettext-devel

二:安装

确保版本至少在1.7.10或以上,如果不是,卸载重装

yum -y remove git

mkdir /tmp/git && cd /tmp/gitcurl --progress https://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz | tar xzcd git-2.1.3/./configuremakemake prefix=/usr/local install创建软连接ln -s /usr/local/bin/git /usr/bin/git

三:安装ruby

注意:请不要用rvm安装ruby,否则,后续会出现一些难以解决的问题

Gitlab7.x需要ruby2.x

如果系统自带的ruby版本低于2.x,就需要升级ruby

yum remove ruby

或者

cd 
make uninstall

mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz | tar xzcd ruby-2.1.2./configure --disable-install-rdocmakemake prefix=/usr/local install

安装bundler

gem source -r 

gem source -a http://ruby.taobao.org/

gem install bundler --no-doc

四:系统配置

执行命令:visudo

/usr/local/bin加入到secure_path里面去

然后,配置git用户可以使用sudo

git ALL=(ALL) ALL

五:配置

配置用户名,密码

创建

CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;注意:这里选择了mysql,则还需要安装mysql的开发包Yum install mysql-devel数据库如果选择的是pg,则也需要安装pg的开发包

五:配置

需要把.conf配置文件的

unixsocket/tmp/redis.sock

unixsocketperm777

这两项注释放开

Redis-serverredis.conf启动redis

执行chmod777 /tmp/redis.sock

六:安装gitlab(使用git用户)

1:注意,这里必须用git clone下载(在git用户家目录下执行),不要下载网上已经打包好的tar.gz文件,否则以后不能升级git clone https://gitlab.com/gitlab-org/gitlab-ce.git gitlabcd /home/git/gitlab  (注意目录位置,尽量使用默认的)

然后,切换到你需要安装的版本上

这里安装的是v7.9.2

git checkout v7.9.2(注意这里是tag)

git checkout -b gitlab-7-9-2

2:复制配置文件

cp config/gitlab.yml.example config/gitlab.yml编辑config/gitlab.yml修改host 为当前机器的ip地址修改port为gitlab运行的端口地址,需要和下面的unicorn.rb配置的端口保持一致cp config/unicorn.rb.example config/unicorn.rb编辑config/unicorn.rb把listen "127.0.0.1:8080"改成listen "8080"cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rbcp config/resque.yml.example config/resque.yml修改config/resque.yml把production的值改成:unix:/tmp/redis.sock cp config/database.yml.mysql config/database.yml(请注意自己使用的数据库类型)配置用户名,密码,数据库名称3:授权目录chmod -R u+rwX tmp/pids/chmod -R u+rwX tmp/sockets/chmod -R u+rwX  public/uploadschown -R git log/chown -R git tmp/chmod -R u+rwX log/chmod -R u+rwX tmp/mkdir /home/git/gitlab-satelliteschmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellitesmkdir tmp/backups

4:配置git

git config --global user.name "GitLab"

git config --global user.email "scm@xiangrikui.com"

git config --global core.autocrlf input

5:修改Gemfile

vim Gemfile

修改sourcehttp://ruby.taobao.org

加入下面的gem

gem 'therubyracer'gem 'execjs'

注意:如果系统中安装了,则不需要添加这2gem

6:bundle installbundle install --no-deployment --without development test postgres aws中途如果不出意外的话,就安装完成(install中途可能要提示输入密码)如果提示类似下面的错误:An error occurred while installing ace-rails-ap (2.0.1), and Bundler cannot continue.Make sure that `gem install ace-rails-ap -v '2.0.1'` succeeds before bundling.类似这样的,需要手动安装的gem ,请手动安装,然后继续执行上面的bundle install7:安装gitlab-shell(需要联网)bundle exec rake gitlab:shell:install[v2.6.0] REDIS_URL=unix:/tmp/redis.sockRAILS_ENV=productionchmod -R ug+rwX,o-rwx /home/git/repositories/chmod -R ug-s /home/git/repositories/find /home/git/repositories/ -type d -print0 | sudo xargs -0 chmod g+s注意,这里的v2.6.0要和GITLAB_SHELL_VERSION文件里面的版本号保持一致unix:/tmp/redis.sock要和redis.conf里面的配置unixsocket保持一致8:初始化数据库bundle exec rake gitlab:setup RAILS_ENV=production成功的话,会输出Administrator account created:login.........admin@local.hostpassword......5iveL!fe记住这里的用户名和密码9:预编译bundle exec rake assets:precompile RAILS_ENV=production如果报了下面的错误rake aborted!Sprockets::FileNotFound: couldn't find file 'jquery.ui.all'  (in /home/git/gitlab/app/assets/javascripts/application.js.coffee:8)则,需要修改Gemfilegem "jquery-ui-rails" 改成gem "jquery-ui-rails", “4.0.2”然后,重新执行上面的bundle install10:拷贝启动脚本sudo cp lib/support/init.d/gitlab /etc/init.d/gitlabsudo cp lib/support/init.d/gitlab.default.example /etc/default/gitlabsudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab然后通过/etc/init.d/gitlab start,stop,restart启动,关闭gitlab11:验证启动服务:/etc/init.d/gitlab start观察/home/git/gitlab/log目录的日志,bundle exec rake gitlab:check RAILS_ENV=production修复这里输出的错误信息12:登陆系统输入ip和端口访问系统用上面的用户名和密码登陆系统然后,修改密码

管理gitlab

一:gitlab的备份与恢复

备份:bundleexec rake gitlab:backup:create RAILS_ENV=production

还原:bundleexec rake gitlab:backup:restore RAILS_ENV=production

二:gitlab的升级

升级的思路一般是:

(1)备份

(2)升级ruby

(3)gitpull(获取最新的gitlab源代码,所以说安装的时候,就要用git获取源代码)

(4)执行一些其他的配置

每个版本升级到最新版,配置都不一样,具体升级请看

https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update

转载地址:http://spfsn.baihongyu.com/

你可能感兴趣的文章
3.2servlet功能和会话技术
查看>>
3.3servlet三大作用域
查看>>
泛型详解
查看>>
集合案例:斗地主
查看>>
软件测试进阶篇
查看>>
二叉搜索树的实现
查看>>
连续最大和
查看>>
不要二题目
查看>>
合法括号序列判断
查看>>
两种排序方法
查看>>
最小公倍数
查看>>
淘宝购物车测试用例
查看>>
Java语言基础(多态,抽象类,接口)
查看>>
Java语言基础(内部类,匿名内部类,object类)
查看>>
Java语言基础(数组冒泡排序,选择排序等,二分法)
查看>>
史上最全的集合(集合UML图(Collection集合和Map集合)详解,子接口(list和set)泛型)
查看>>
IO流(字节流和字符流)
查看>>
P1563 玩具谜题
查看>>
L1-002 打印沙漏 (20分)
查看>>
P1217 [USACO1.5]回文质数 Prime Palindromes
查看>>