Created
May 13, 2012 05:53
-
-
Save Bigcircle/2686138 to your computer and use it in GitHub Desktop.
centos搭ror环境
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 163源 | |
cd /etc/yum.repos.d | |
mv CentOS-Base.repo CentOS-Base.repo.save | |
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo | |
mv CentOS6-Base-163.repo CentOS-Base.repo | |
# 更新yum并立即生效 | |
yum check-update | |
yum update | |
yum makecache | |
# 安装wget,vim | |
yum -y install vim-enhanced wget | |
mkdir ~/Downloads | |
cd ~/Downloads | |
# 编译所需库文件,编译器 | |
yum -y install openssl-devel zlib-devel gcc gcc-c++ curl-devel expat-devel gettext-devel make automake autoconf readline-devel libtool | |
# 如果已存在ruby,删除原有版本 | |
yum erase ruby ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs | |
# 可能需要手动安装 libyaml 和 libffi, 不然编译的时候一些文件编译出错 | |
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
wget ftp://sourceware.org/pub/libffi/libffi-3.0.11.tar.gz | |
tar zxvf xxx && ./configure && make && sudo make install | |
# 去ruby-lang查找最新/需要的ruby版本,用户名为 annoymous,密码空 | |
ftp ftp.ruby-lang.org | |
cd /pub/ruby && ls | |
get ruby-1.9.3-p286.tar.gz | |
# 或者直接用 wget / curl | |
wget http://ftp.ruby-lang.org/pub/ruby/ruby-1.9.3-p286.tar.gz | |
tar zxvf ruby-1.9.3-p286.tar.gz | |
cd ruby-1.9.3-p286 | |
./configure && make && sudo make install | |
# 如果编译的时候是自己指定路径则需要配置环境变量 | |
# 在/etc/profile后加入 Ruby环境变量 | |
# export PATH=/usr/local/ruby/bin:$PATH | |
# source /etc/profile | |
ruby -v / which ruby | |
# ruby 1.9+ 之后默认自带rubygems,不过 1.8.7版本还需要自己安装 | |
wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.16.tgz | |
tar zxvf rubygems-1.8.16.tgz | |
cd rubygems-1.8.16 | |
ruby setup.rb | |
gem -v | |
# 安装gem包的问题 | |
# 很多 linux 发行版上的sudo路径的问题,通过下面2个命令就可以看出有和没有sudo PATH是不一样的 | |
echo 'echo $PATH' | sh | |
echo 'echo $PATH' | sudo sh | |
# 解决办法 alias 或者 改造 sudo文件 | |
# http://stackoverflow.com/questions/257616/sudo-changes-path-why | |
alias sudo='sudo env PATH=$PATH' | |
mv /usr/bin/sudo /usr/bin/sudo.orig | |
cat > /usr/bin/sudo <<EOF | |
#!/bin/bash | |
/usr/bin/sudo.orig env PATH=$PATH "$@" | |
EOF | |
# 安装mysql2这个gem包的时候会提示缺少mysql.h头文件,简单的解决办法就是重装mysql.. | |
yum remove mysql | |
yum -y install mysql mysql-server mysql-devel | |
service mysqld start | |
mysql -uroot | |
# Could not find a JavaScript runtime 原因:linux下默认没有js引擎 | |
# 在Gemfile中添加2个gem并重新bundle install | |
gem 'execjs' # run js code from ruby | |
gem 'therubyracer' # google V8 embedded in ruby | |
# 或者注释掉 group 'assets' 中的几个gem | |
# 或者在系统中装一个Js引擎,比如Nodejs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment