在公司内网服务器上面搭建gdk环境,踩了很多坑,历时四五天(中间涉及申请开通固定外网),整理如下:
总览:
操作系统:redhat 6.3
参考文档:https://gitlab.com/gitlab-org/gitlab-development-kit
准备阶段
申请开通网络
registry.npm.taobao.org
registry.yarnpkg.com
yarnpkg.com
upyun.gems.ruby-china.org
nm.ctn.aicdn.com
yum.postgresql.org
download.fedoraproject.org
get.rvm.io
keys.gnupg.net
cache.ruby-china.org
gitlab.com
github.com
gems.ruby-china.org
配置代理/etc/profile中追加:
http_proxy=http://192.168.XX.XX:8080
https_proxy=$http_proxy
no_proxy=XX.XX.XX.XX,XX.XX.XX.XX
export http_proxy https_proxy no_proxy
新建用户gitdev
user add gitdev
开通sudo权限,在/etc/sudoers后追加:
gitdev ALL=(ALL) ALL
注意:sodu出现环境变量问题引起的命令找不到时,设置secure_path即可。
以下安装都用gitdev用户进行
安装步骤
安装ruby
下载安装包:ruby-2.4.1.tar.gz
tar –xvzf ruby-2.4.1.tar.gz
cd ruby-2.4.1
./configure
make
sudo make install
安装/更新本地的nodejs和npm
下载最新版本的npm和node:http://nodejs.cn/download/
node-v8.2.1-linux-x64.tar.xz
解压
/opt/software/node-v8.2.1-linux-x64
设置环境变量
$ vim /etc/profile
export NODE_HOME=/opt/software/node-v8.2.1-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
配置npm源到公司源(如果没有公司的npm源,可配置到淘宝源):
npm config set registry=https://XXX.XX.com
修改gem源
gem sources --add http://gems.ruby-china.org/ --remove https://rubygems.org/
注意:执行过程中openssl相关报错
安装openssl和openssl-devel
然后到ruby的安装目录执行:
ruby extconfig.rb
make
make install
过程中报错:make: *** No rule to make target `/thread_native.h', needed by `ossl.o'. Stop.
其实是ext/openssl/Makefile中忘了给路径变量top_srcdir赋值,调用的时候当然就报错了,修改 Makefile 增加 top_srcdir = ../..
安装rails
gem install rails –y
测试执行命令时报错:
rails server
rails g controller events
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
进入ruby源码文件夹
安装ruby自身提供的zlib包
#cd ext/zlib
#ruby ./extconf.rb
#make
#make install
来源: <http://blog.csdn.net/kenera/article/details/6524557>
报错信息;
make: *** No rule to make target `/thread_native.h', needed by `ossl.o'. Stop.
解决这个问题,修改 Makefile 增加 top_srcdir = ../.. 即可。
Preparing your computing environment for GDK
进入页面:https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/prepare.md
页面给出的提示,要仔细阅读并遵照执行,否则会走很多弯路:
Prerequisites for all platforms
If you do not have the dependencies below you will experience strange errors
during installation.
A non-root Unix user, this can be your normal user but DO NOT run the
installation as a root user
Ruby 2.3 (2.3.3 or newer) installed with a Ruby version manager
(RVM, rbenv, chruby, etc.), DO NOT use the
system Ruby
Bundler, which you can install with gem install bundler
Git version of 2.7.X or higher
Node 4.3 or newer and Yarn 0.17 or newer. If your package manage does not
have up-to-date versions of node or yarn available, visit the official
websites for node and yarn for installation instructions.
Go 1.8.3 or newer. If your package manager does not have up-to-date versions
of Go available, visit the official website for go for installation instructions.
找到对应的操作系统安装步骤,本例中是centos,所以,执行centos的安装步骤:
CentOS
页面步骤:
Please read the prerequisites for all platforms.
This is tested on CentOS 6.5:
sudo yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-