最新消息:欢迎加入小松的QQ群一起讨论一起学习,搜索页面修改成lua+ElasticSearch,使用php这个页面速度相对慢一点,优化之后速度杠杠的,如有问题请加群联系我

centos 32位下安装gitlab

Linux 887浏览 0评论

centos 32位下安装gitlab

目前系统的环境
centos6.4 32位
已经安装mysql nginx

下载并安装GPG key

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.rpm

PS.不要在意x86_64(64位),在i686(32位)的机器上一样能使用

增加PUIAS安装源

vi /etc/yum.repos.d/PUIAS_6_computational.repo

添加如下内容:

[PUIAS_6_computational]
name=PUIAS computational Base $releasever - $basearch
mirrorlist=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch/mirrorlist
#baseurl=http://puias.math.ias.edu/data/puias/computational/$releasever/$basearch
gpgcheck=1
gpgkey=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-puias

安装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 git

配置redis

chkconfig redis on
service redis start

安装Ruby

su -
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz| tar xz
cd ruby-2.3.0
./configure --prefix=/usr/local/
make && make install

PS.安装完成后,重新登录终端确保$PATH生效,检测ruby的安装成功与否:

ruby -v

安装bundle

gem install bundler --no-ri --no-rdoc

创建用户git

adduser --system --shell /bin/bash --comment 'GitLab' --create-home --home-dir /home/git/ git

PS.因为git用户不需要登录,所以这里不需要设置git的密码

下载gitlab shell

https://github.com/gitlabhq/gitlab-shell/tree/v2.7.2
我这里用游览器下载的然后传到服务器上,然后修改权限

chmod -R 777 /home/git/gitlab-shell

也可以用git下载,但是比较慢

su - git
git clone https://github.com/gitlabhq/gitlab-shell.git
cd gitlab-shell
git checkout v3.4.0

我这里安装的是2.7.2

配置gitlab shell

cd gitlab-shell
cp config.yml.example config.yml

这里最重要的是将gitlab_url修改成gitlab的访问域名。比如:http://git.phpsong.com/

修改hosts

vi /etc/hosts

添加

127.0.0.1 git.phpsong.com

安装一些需要的目录和文件

./bin/install

安装GitLab

下载地址
https://github.com/gitlabhq/gitlabhq/tree/7-14-stable
我这里用游览器下载的然后传到服务器上,然后修改权限

chmod -R 777 /home/git/gitlab

也可以用git下载,但是比较慢

su - git
git clone https://github.com/gitlabhq/gitlabhq.git gitlab
cd /home/git/gitlab
git checkout 7-14-stable

配置项目

cd /home/git/gitlab
cp config/gitlab.yml.example config/gitlab.yml
sed -i 's|localhost|git.phpsong.com|g' config/gitlab.yml

su -
cd /home/git/gitlab
chown -R git log/
chown -R git tmp/
chmod -R u+rwX log/
chmod -R u+rwX tmp/
chmod -R u+rwX tmp/pids/
chmod -R u+rwX tmp/sockets/
chmod -R u+rwX public/uploads

su - git
mkdir /home/git/gitlab-satellites

cd /home/git/gitlab
cp config/unicorn.rb.example config/unicorn.rb

配置数据库访问文件

cp config/database.yml.mysql config/database.yml
vi config/database.yml

比如我的配置

#
# PRODUCTION
#
production:
  adapter: mysql2
  encoding: utf8
  collation: utf8_general_ci
  reconnect: false
  database: gitlabhq_production
  pool: 10
  username: root
  password: "123456"
  # host: localhost
  # socket: /tmp/mysql.sock

PS.MySQL的引擎必须是Innodb,myisam的安装会失败,可以用mysql命令show engines查看

安装Gems

su -
gem install charlock_holmes

初始化数据和激活高级功能

PS.修改gitlab目录下的Gemfile和Gemfile.lock问首行的域名rubygems.org修改成ruby.taobao.org,修改之后执行名的命令就会比较快

su - git
cd /home/git/gitlab/
bundle install --deployment --without development test postgres puma aws
bundle exec rake gitlab:setup RAILS_ENV=production

PS.安装的时候出现如下错误
gems/execjs-2.6.0/lib/execjs/runtimes.rb:48:in `autodetect
解决方法
安装nodejs  http://www.phpsong.com/2117.html
执行

gem install execjs
gem install therubyracer

安装成功之后会显示用户名和密码
login………root
password……5iveL!fe
在执行下面的命令,不然没有样式

bundle exec rake assets:precompile RAILS_ENV=production

安装启动脚本

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

启动GitLab实例

service gitlab start

nginx配置

su -
cp /home/git/gitlab/lib/support/nginx/gitlab /usr/local/nginx/conf/vhost/git.phpsong.com.conf

修改一下里面的配置

vi /usr/local/nginx/conf/vhost/git.phpsong.com.conf
mkdir /var/log/nginx

里面的内容主要修改端口和域名,如我下面的配置

#  listen 0.0.0.0:80 default_server;
#  listen [::]:80 default_server;
listen 80;
server_name git.phpsong.com; ## Replace this with something like gitlab.example.com
检查一下nginx配置
nginx -t

我这里的nginx是www的用户启动

ps aux|grep nginx

将www加入git用户组

usermod -a -G git www

PS. 如果查看/var/log/nginx/gitlab_error.log发现错误connect() to unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket failed错误

connect() to unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket failed

解决方法

vi /usr/local/nginx/conf/vhost/git.phpsong.com.conf

把修改成

upstream gitlab-workhorse {
#  server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}

重要错误日志文件

/home/git/gitlab/log/unicorn.stderr.log
/var/log/nginx/gitlab_error.log

参考网址: http://my.oschina.net/wzlee/blog/262181

QQ交流群:136351212(满) 455721967

如无特别说明,本站文章皆为原创,若要转载,务必请注明以下原文信息:
转载保留版权:小松博客» centos 32位下安装gitlab
本文链接地址:https://www.phpsong.com/2676.html

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
木有头像就木有JJ!点这里按步骤申请Gravatar头像吧!

网友最新评论 (1)

加载中,请稍候...
  1. 你的博客非常不错哦,学习下。
    dearbaba2016-09-10 10:18:28回复