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

[经验分享] gitlab 安装及部署

[复制链接]

尚未签到

发表于 2018-9-19 11:44:09 | 显示全部楼层 |阅读模式
Gitlab 安装部署
  GitLab,是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用。
  安装步骤
  n升级系统并及关闭selinux和iptables
  n安装Ruby
  n创建项目运行用户(创建git账号,方便权限管理)
  nGitLab Shell
  n数据库(可以支持mysql和PostgreSQL,这里使用mysql)
  nGitLab(版本:6.3.1)
  nWeb服务器(可支持nginx和apache,这里使用nginx)
一、基础操作
1、升级系统
  yum -y update
2、关闭selinux和iptables
  # vi /etc/selinux/config  # 设置SELINUX=disabled
  # setup                     #将Firewall 选项取消
DSC0000.jpg

3、增加EPEL安装源
# wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6  检验下是否安装成功
# rpm -qa gpg*  安装epel-release-6-8.noarch包
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm4、增加PUIAS安装源
  创建/etc/yum.repos.d/PUIAS_6_computational.repo,并添加如下内容:
[PUIAS_6_computational]name=PUIAS computational Base $releasever - $basearchmirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist#baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearchgpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puias  下载并安装GPG key
# wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-pui  检测源
# yum repolist5、安装GitLab的所需依赖包和工具
# su -# yum -y groupinstall 'Development Tools'# yum -y install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git6、设置redis开机启动
# chkconfig redis on# service redis start二、安装Ruby
# mkdir /tmp/ruby && cd /tmp/ruby# curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz# cd ruby-2.0.0-p353# ./configure --prefix=/usr/local/# make && make install  安装bundle
# gem install bundler --no-ri --no-rdoc三、创建git系统用户
# adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git四、配置GitLab shell
  克隆gitlab shell
# su - git$ git clone https://github.com/gitlabhq/gitlab-shell.git$ cd gitlab-shell$ git checkout v1.8.0                         #切换版本$ cp config.yml.example config.yml$ vi config.yml  gitlab_url修改成gitlab的访问域名。形如:http://test.gitlab.com/
  如果gitlab是使用https访问,则需将http替换成https,配置文件中的self_signed_cert要修改成true,否则会出错。
  安装
$ ./bin/install五、安装Mysql数据库并设置开机启动
$ su -$ yum install -y mysql-server mysql-devel$ chkconfig mysqld on$ service mysqld start  设置mysql root账号的密码
/usr/bin/mysql_secure_installation  创建新用户和数据库给gitlab使用
mysql> CREATE USER 'gitlab'@'localhost'># 创建gitlaba使用的数据库mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;# 给予gitlab用户权限mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX,>六、安装GitLab
$ su - git克隆GitLab并切换分支到6-3-stable
$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab$ cd /home/git/gitlab$ git checkout 6-3-stable配置
# 复制配置文件$ cp config/gitlab.yml.example config/gitlab.yml# 修改配置文件中的访问域名(your_domain_name为项目的访问域名)$ sed -i 's|localhost|your_domain_name|g' config/gitlab.yml# 设定log和tmp目录所有者和权限$ chown -R git log/$ chown -R git tmp/$ chmod -R u+rwX log/$ chmod -R u+rwX tmp/# 创建gitlab-satellites目录$ mkdir /home/git/gitlab-satellites# 创建tmp/pids/和tmp/sockets/目录,确保gitlab有相应的权限$ mkdir tmp/pids/$ mkdir tmp/sockets/$ chmod -R u+rwX tmp/pids/$ chmod -R u+rwX tmp/sockets/# 创建public/uploads目录$ mkdir public/uploads$ chmod -R u+rwX public/uploads# 复制unicorn配置$ cp config/unicorn.rb.example config/unicorn.rb# 编辑unicorn配置(笔者这里采用默认配置)$ vim config/unicorn.rb# 配置git的用户和邮件$ git config --global user.name "GitLab"$ git config --global user.email "gitlab@your_domain_name"$ git config --global core.autocrlf input配置数据库访问文件
$ cp config/database.yml.mysql config/database.yml  编辑config/database.yml,设置其中连接数据库的账号密码
## PRODUCTION#production:  adapter: mysql2  encoding: utf8  reconnect: false  database: gitlabhq_production  pool: 10  username: gitlab  password: "gitlab"  # host: localhost  # socket: /tmp/mysql.sock  修改其中username和password就可以了
  确保该文件只有git账号有权限读取
$ chmod o-rwx config/database.yml
安装Gems
  由于国外gem源访问非常慢,建议更换国内gem源。
#  vi Gemfile  编辑Gemfile文件,将gem源更换为ruby.taobao.org
  #source"https://rubygems.org"
  sourcehttp://ruby.taobao.org
  修改Gemfile文件,将gem "modernizr", "2.6.2"修改为gem"modernizr-rails", "2.7.1"。
修改Gemfile.lock文件,将modernizr (2.6.2)修改为modernizr-rails (2.7.1)。否则无法正确安装。# gem install charlock_holmes --version '0.6.9.4'安装mysql包
$ cd /home/git/gitlab/$ bundle install --deployment --without development test postgres puma aws初始化数据
$ cd /home/git/gitlab$ bundle exec rake gitlab:setup RAILS_ENV=production$ bundle exec rake assets:precompile RAILS_ENV=production  这步完成后,会生一个默认的管理员账号:
admin@local.host5iveL!fe安装启动脚本
$ su -$ wget -O /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/init/sysvinit/centos/gitlab-unicorn$ chmod +x /etc/init.d/gitlab$ chkconfig --add gitlab  开机时启动
$ chkconfig gitlab on检测应用程序状态
$ su - git$ cd gitlab/$ bundle exec rake gitlab:env:info RAILS_ENV=production$ exit  可以查看到系统、Ruby、GitLab和GitLab Shell的版本和其他信息。
  启动GitLab实例
$ service gitlab start  查看应用更加详细的信息
$ su - git$ cd gitlab/$ bundle exec rake gitlab:check RAILS_ENV=production七、安装web服务器nginx
$ su -$ yum -y install nginx$ chkconfig nginx on$ mkdir /etc/nginx/sites-available$ mkdir /etc/nginx/sites-enabled$ wget -O /etc/nginx/sites-available/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/master/web-server/nginx/gitlab-ssl$ ln -sf /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab  编辑/etc/nginx/nginx.conf,将 include /etc/nginx/conf.d/*.conf; 替换成include /etc/nginx/sites-enabled/*;,就是修改额外加载的配置文件目录。
  编辑/etc/nginx/sites-available/gitlab,将配置中server_name替换成实际访问的域名。
  将nginx加入git用户组
$ usermod -a -G git nginx$ chmod g+rx /home/git/  添加ssl证书或者自己生成一个
$ cd /etc/nginx$ openssl req -new -x509 -nodes -days 3560 -out gitlab.crt -keyout gitlab.key  启动nginx
$ service nginx start登录Gitlab 如下图所示:
DSC0001.jpg

rpm安装Gitlab
  详情请查看官网:https://www.gitlab.com/downloads/
  启动gitlab
# /opt/gitlab/bin/gitlab-ctl startok: run: nginx: (pid 2505) 0sok: run: postgresql: (pid 2509) 1sok: run: redis: (pid 2518) 0sok: run: sidekiq: (pid 2523) 1s  ok: run: unicorn: (pid 2528) 0s
  参考文档
  http://www.01happy.com/centos-6-5-install-gitlab/
  http://www.it165.net/os/html/201405/8123.html



运维网声明 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-594223-1-1.html 上篇帖子: gitlab 安装报错:Could not find modernizr-2.6.2 in any of the sources-David 下篇帖子: GitLab安装篇-Ubuntu 14.04 LTS
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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