anyenvという便利なものを見つけたので入れてみます。
rubyだけじゃなくphpとかnodeとかも快適に使いたいので。
rbenvの削除
もともとrbenvだけ使ってたので削除します。
$ brew uninstall rbenv
$ brew uninstall ruby-build
anyenvのインストール
$ git clone https://github.com/riywo/anyenv ~/.anyenv
$ vi .bash_profile
//以下を追加
if [ -d $HOME/.anyenv ] ; then
export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"
# tmux対応
for D in `\ls $HOME/.anyenv/envs`
do
export PATH="$HOME/.anyenv/envs/$D/shims:$PATH"
done
fi
$ source .bash_profile
phpenv, rbenvを入れる
$ anyenv install phpenv
$ anyenv install rbenv
$ anyenv versions
phpenv:
* system (set by /Users/ryo/.anyenv/envs/phpenv/version)
rbenv:
* system (set by /Users/ryo/.anyenv/envs/rbenv/version)
ruby 2.3.4のインストール
$ rbenv install 2.3.4
$ rbenv global 2.3.4
$ rbenv rehash
$ ruby -v
php 5.6.30のインストール
インストールしようとしたらエラーが出ないので追加でモジュールをインストールします。
$ phpenv install 5.6.30
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
-----------------------------------------
$ brew install libmcrypt
それでもopenssl関連でエラーがまた出ます。
$ phpenv install 5.6.30
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
_Nullable
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/stdio.h:475:6: note: insert '_Nonnull' if the pointer should never be null
FILE *funopen(const void *,
^
_Nonnull
/var/tmp/php-build/source/5.6.30/ext/openssl/openssl.c:44:10: fatal error: 'openssl/evp.h' file not found
#include <openssl/evp.h>
^
330 warnings and 1 error generated.
make: *** [ext/openssl/openssl.lo] Error 1
-----------------------------------------
なんか調べてみると、ビルド時のオプションを指定してやらねばならなそう。
$ brew install openssl libxml2 autoconf automake libjpeg libpng libmcrypt
$ PHP_BUILD_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl) --with-libxml-dir=$(brew --prefix libxml2)" PHP_BUILD_EXTRA_MAKE_ARGUMENTS=-j4 phpenv install 5.6.30
すごいやり方だけど、環境変数にとりあえず置いといても良さそう。
コンパイルうまくいくと、macbookのファンが少しうなる。
まあ一旦これで行けたのでよし。
nodenvもインストールする
node.js環境も整えたいのでnodenvもインストールします。
$ anyenv install nodenv
$ exec $SHELL -l
$ nodenv --version
nodenv 1.1.0-3-g27f0d7b
とりあえず最新版を入れてみます。
$ nodenv install 7.10.0
$ nodenv global 7.10.0
$ nodenv rehash
$ node -v
v7.10.0
特に問題なくインストールできました。