centos 32位下安装gitlab

来源:互联网 发布:windows资源管理器 编辑:程序博客网 时间:2024/06/08 13:50

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.txtrpm --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 - $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-puiasrpm --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 onservice redis start

安装Ruby

su -mkdir /tmp/ruby && cd /tmp/rubycurl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz| tar xzcd 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 - gitgit clone https://github.com/gitlabhq/gitlab-shell.gitcd gitlab-shellgit checkout v3.4.0

我这里安装的是2.7.2

配置gitlab shell

cd gitlab-shellcp 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 - gitgit clone https://github.com/gitlabhq/gitlabhq.git gitlabcd /home/git/gitlabgit checkout 7-14-stable

配置项目

cd /home/git/gitlabcp config/gitlab.yml.example config/gitlab.ymlsed -i 's|localhost|git.phpsong.com|g' config/gitlab.ymlsu -cd /home/git/gitlabchown -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/uploadssu - gitmkdir /home/git/gitlab-satellitescd /home/git/gitlabcp config/unicorn.rb.example config/unicorn.rb

配置数据库访问文件

cp config/database.yml.mysql config/database.ymlvi 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 - gitcd /home/git/gitlab/bundle install --deployment --without development test postgres puma awsbundle 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 execjsgem 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-unicornchmod +x /etc/init.d/gitlabchkconfig --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.confmkdir /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

0 0