## 1. はじめに
mac mini 2018 late を購入し、開発環境を構築しようとして早1ヶ月。Qiitaの記事を書きながら進めているためか、なかなか開発できずに現在に至ります。。。
さて、今回は、anyenvについて書きます。
ruby使いの私にとって、rubyのバージョン切り替えなどが便利なrbenvは必須なのですが、pythonやphpにも興味があり、同じバージョン管理ができるanyenvの導入を決めました。
(と言っても、もともと使ってたmac miniやmacbook proもanyenvに入れ替えたんですけどね。。。)
anyenvはHomebrewにもfomulaがありますが、anyenv自体が自力でバージョンアップできることから、下手にHomebrewは用いずにgithubからcloneすることで最新版を取得して構築することにしました。
2. 目次
1. はじめに
2. 目次
3. anyenvとは
4. インストール
4.1. インストールのための準備
4.2. githubからのcloneによるインストール
4.3. インストール後の環境設定
5. 簡単な使い方
5.1. コマンドの使い方
5.2. anyenvを用いた各**envの更新方法
5.3. rbenvのインストール
5.4. pyenvのインストール
5.5. phpenvのインストール
5.5.1 phpenvのインストール
5.5.2 phpのインストール
5.5.3 htmlとの連携に必要なmoduleの切り替えについて
6. さいごに
7. 参考サイト
3. anyenvとは
LinuxやMacにおいて、複数のバージョンの実行環境を管理するツールとして、**env
(pyenv
、rbenv
、phpenv
......etc)があります。
この**env
自体を管理するツールがanyenv
です。
各**env
自身のバージョンを更新できるだけでなく、自分自身のバージョンも更新できるできることがとても強みです。
4. インストール
では実際にインストールしていきたいと思います。
今回はgithubからインストールを行います。
4.1 インストールのための準備
4.1.1. インストール先の確保
システムワイドにインストールするため、インストール先を確保する必要があります。
今回は/opt
の下に環境を構築します。
以下のコマンドでanyenv
のディレクトリを作成し、権限を与えます。
これを実行するには管理者権限での実行が必要です。
$ sudo mkdir -p /opt/anyenv
$ sudo chown ${USER}:staff /opt/anyenv
$ sudo chmod 775 /opt/anyenv
インストールはこの/opt/anyenvに行っていきます。
4.1.2. /etc/profile.dの構築
また、インストール後の環境設定をシステムワイドに実施するに当たって、直接/etc/profile
に書き込むのも良いですが、何をどこに書いたかわからなくなるため、/etc/profile.d
を作成してそこに各内容毎のスクリプトを作成することで管理できるようにします。
まず、以下のコマンドで/etc/profile.d
を作成します。
$ sudo mkdir /etc/profile.d
次に、/etc/profile
に以下を追記します。
(管理者権限で編集が必要のため、sudo vi /etc/profile
を実行してください。)
/etc/profile:(Apend)
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
source "$i"
else
source "$i" >/dev/null 2>&1
fi
fi
done
これで環境設定ファイルを格納する準備が整いました。
ちなみにこのprofile用のディレクトリは、anyenvに限らずbashにて環境設定を実施する場合に有効です。
4.2 githubからのcloneによるインストール
今回はgithubからcloneによってインストールしていきます。
コマンドは以下の通りです。
$ git clone https://github.com/anyenv/anyenv /opt/anyenv
Cloning into '/opt/anyenv'...
remote: Enumerating objects: 384, done.
remote: Total 384 (delta 0), reused 0 (delta 0), pack-reused 384
Receiving objects: 100% (384/384), 65.00 KiB | 365.00 KiB/s, done.
Resolving deltas: 100% (170/170), done.
必要なコマンド群はこのcloneのみで入ります。
しかし、これらを使えるようにするにはこの後の環境設定が重要となります。
4.3 インストール後の環境設定
今回、システムワイドにインストールを実施したので、環境設定もシステムワイドに行えるようにする必要があります。
通常は~/.bash_profile
に設定を書き込むのですが、今回はどのユーザでも実行できるよう、4.1.2.で作成したように以下の場所にファイルを作成して書き込むことにしました。
/etc/profile.d/anyenv.sh
export PATH="/opt/anyenv/bin:$PATH"
export ANYENV_ROOT="/opt/anyenv"
eval "$(anyenv init -)"
4.4 動作確認
現時点では、以下のようにコマンドは認識できません。
$ which anyenv
動作確認をするためには、作成した環境設定を現在動作中のコマンドラインでも有効にする必要があります。
この場合は以下のコマンドにて有効にすることができます。
$ source /etc/profile.d/anyenv.sh
ANYENV_DEFINITION_ROOT(/Users/takerulocal/.config/anyenv/anyenv-install) doesn't exist. You can initialize it by:
> anyenv install --init
すると、このようなメッセージが出てきました。
多分eval "$(anyenv init -)
の実行の際に、anyenv initall --init
が事前に実行されていないがために出てきたメッセージでしょう。
指示通りにコマンドを実行します。
$ anyenv install --init
Manifest directory doesn't exist: /Users/${USER}/.config/anyenv/anyenv-install
Do you want to checkout ? [y/N]: y
Cloning https://github.com/anyenv/anyenv-install.git master to /Users/${USER}/.config/anyenv/anyenv-install...
Cloning into '/Users/takerulocal/.config/anyenv/anyenv-install'...
remote: Enumerating objects: 48, done.
remote: Total 48 (delta 0), reused 0 (delta 0), pack-reused 48
Unpacking objects: 100% (48/48), done.
Completed!
githubからanyenv-installをcloneしているのが気になりますが、どうも設定関係をcloneしてきているようですね。
しかも、各ユーザのhome
ディレクトリに.config
というディレクトリを作成してcloneしてきているようです。
ということは、システムワイドに環境構築しても設定だけはユーザ毎に保持できる、という解釈で良いのでしょうか。
この辺はもう少し調査が必要のようです。
では、もう一度以下のコマンドを実行します。
$ source /etc/profile.d/anyenv.sh
今度は問題なく実行できました。
では、anyenvコマンドが認識できるか確認しましょう。
$ which anyenv
/opt/anyenv/bin/anyenv
返ってきました。
試しにanyenv help
を実行しましょう。
$ anyenv help
Usage: anyenv <command> [<args>]
Some useful anyenv commands are:
commands List all available anyenv commands
local Show the local application-specific Any version
global Show the global Any version
install Install a **env
uninstall Uninstall a specific **env
version Show the current Any version and its origin
versions List all Any versions available to **env
See `anyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/anyenv/anyenv#readme
返ってきましたね。
これでインストールは完了です。
4.5. anyenvで更新できるようにするために必要なこと
anyenvで各**env
を更新できるようにするためには、プラグインであるanyenv-update
をインストールする必要があります。
以下を実行してください。
#anyenvのディレクトリにpluginsディレクトリを作成
$ mkdir -p $(anyenv root)/plugins
#githubのanyenv-updateというプラグインをインストール
$ git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update
#更新する
$ anyenv update
5. 簡単な使い方
では実際に使って行ってみましょう。
5.1 コマンドの使い方
これはanyenv help
を見れば一覧が出てきます。
$ anyenv help
Usage: anyenv <command> [<args>]
Some useful anyenv commands are:
commands List all available anyenv commands
local Show the local application-specific Any version
global Show the global Any version
install Install a **env
uninstall Uninstall a specific **env
version Show the current Any version and its origin
versions List all Any versions available to **env
See `anyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/anyenv/anyenv#readme
では実際にコマンドを打ってみましょう。
インストールできる**envの一覧表示は以下の通りです。
$ anyenv install --list
Renv
crenv
denv
erlenv
exenv
goenv
hsenv
jenv
luaenv
nodenv
phpenv
plenv
pyenv
rbenv
sbtenv
scalaenv
swiftenv
tfenv
5.2. anyenvを用いた各**envの更新方法
anyenv自身は以下のコマンドで更新します。
このコマンドを実行すると、インストールされている全ての**envを更新します。
$ anyenv update
Updating 'anyenv'...
Updating 'anyenv/anyenv-update'...
Updating 'anyenv manifest directory'...
5.3. rbenvのインストール
では実際にrbenv
をインストールしてみましょう。
$ anyenv install rbenv
/var/folders/41/zgvgyyr923l_y69p_mv7qdsm0000gn/T/rbenv.20190907220217.74681 ~
Cloning https://github.com/rbenv/rbenv.git master to rbenv...
Cloning into 'rbenv'...
remote: Enumerating objects: 2759, done.
remote: Total 2759 (delta 0), reused 0 (delta 0), pack-reused 2759
Receiving objects: 100% (2759/2759), 526.02 KiB | 373.00 KiB/s, done.
Resolving deltas: 100% (1731/1731), done.
~
/opt/anyenv/envs/rbenv/plugins ~
Cloning https://github.com/rbenv/ruby-build.git master to ruby-build...
Cloning into 'ruby-build'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 9812 (delta 6), reused 11 (delta 1), pack-reused 9791
Receiving objects: 100% (9812/9812), 2.09 MiB | 221.00 KiB/s, done.
Resolving deltas: 100% (6371/6371), done.
~
Install rbenv succeeded!
Please reload your profile (exec $SHELL -l) or open a new session.
インストールされました。
どうやらrbenvで指定したrubyのバージョンをインストールを実行するために必要なruby-buildも含めてインストールされるようです。
メッセージに書かれているように、exec $SHELL -l
を実行してprofile
を再読み込みしましょう。
$ exec $SHELL -l
動作確認を以下のコマンドで行います。
$ rbenv help
Usage: rbenv <command> [<args>]
Some useful rbenv commands are:
commands List all available rbenv commands
local Set or show the local application-specific Ruby version
global Set or show the global Ruby version
shell Set or show the shell-specific Ruby version
install Install a Ruby version using ruby-build
uninstall Uninstall a specific Ruby version
rehash Rehash rbenv shims (run this after installing executables)
version Show the current Ruby version and its origin
versions List installed Ruby versions
which Display the full path to an executable
whence List all Ruby versions that contain the given executable
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme
このように表示されれば成功です。
では、rubyのインストールまでしてみましょう。
まず、以下のコマンドを実行して指定するrubyのバージョンを確認します。
$ ruby install --list
最新安定バージョンである2.6.4をインストールします。
$ ruby install 2.6.4
ruby-build: using openssl from homebrew
Downloading ruby-2.6.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.4.tar.bz2
Installing ruby-2.6.4...
Installed ruby-2.6.4 to /opt/anyenv/envs/rbenv/versions/2.6.4
この処理には非常に時間がかかります。
何も表示されないのでわかりにくいですが、実際にはrubyのコンパイルが実行されております。
インストールが成功しました。
しかし、このままではインストールしたバージョンのrubyが実行されません。rbenvでインストールされているバージョンの確認を行います。
$ rbenv versions
* system (set by /opt/anyenv/envs/rbenv/version)
2.6.4
2.6.4がインストールされていますが、systemの方に*がついています。
これは、Macに標準インストールされているrubyを指しています。
このままでruby -v
を実行すると、以下の通りになります。
$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
2.3.7と表示されました。
2.6.4を実行環境とするように変更してみましょう。
$ rbenv global 2.6.4
$ ruby -v
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]
無事に2.6.4に変更されました。
5.4. pyenvのインストール
では今度はpythonのインストール環境を構築します。
$ anyenv install pyenv
/var/folders/41/zgvgyyr923l_y69p_mv7qdsm0000gn/T/pyenv.20190908020403.95747 ~
Cloning https://github.com/pyenv/pyenv.git master to pyenv...
Cloning into 'pyenv'...
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 17369 (delta 4), reused 12 (delta 4), pack-reused 17352
Receiving objects: 100% (17369/17369), 3.38 MiB | 1.33 MiB/s, done.
Resolving deltas: 100% (11822/11822), done.
~
Install pyenv succeeded!
Please reload your profile (exec $SHELL -l) or open a new session.
$ exec $SHELL -l
$ which pyenv
/opt/anyenv/envs/pyenv/bin/pyenv
pyenvのインストールに成功しました。
では、anaconda3をインストールしてみましょう。
最初にインストールするバージョンを確認します。
$ pyenv install --list
今回は、最新バージョンであるanaconda3-2019.07
をインストールします。
$ pyenv install anaconda3-2019.07
Downloading Anaconda3-2019.07-MacOSX-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-2019.07-MacOSX-x86_64.sh
Installing Anaconda3-2019.07-MacOSX-x86_64...
Installed Anaconda3-2019.07-MacOSX-x86_64 to /opt/anyenv/envs/pyenv/versions/anaconda3-2019.07
$ pyenv versions
* system (set by /opt/anyenv/envs/pyenv/version)
anaconda3-2019.07
$ python global anaconda3-2019.07
$ python --version
Python 3.7.3
これでpythonもanyenv環境になりました。
5.5. phpenvのインストール
次にphpをインストールします。。。
しかしながら、phpはコンパイルに少々癖があり、Homebrewで不足パッケージをインストールしながらとなります。
5.5.1. phpenvのインストール
以下のコマンドを実行します。
$ anyenv install phpenv
/var/folders/41/zgvgyyr923l_y69p_mv7qdsm0000gn/T/phpenv.20190908022127.98569 ~
Cloning https://github.com/phpenv/phpenv.git master to phpenv...
Cloning into 'phpenv'...
remote: Enumerating objects: 1205, done.
remote: Total 1205 (delta 0), reused 0 (delta 0), pack-reused 1205
Receiving objects: 100% (1205/1205), 228.54 KiB | 469.00 KiB/s, done.
Resolving deltas: 100% (745/745), done.
~
/opt/anyenv/envs/phpenv/plugins ~
Cloning https://github.com/php-build/php-build.git master to php-build...
Cloning into 'php-build'...
remote: Enumerating objects: 35, done.
remote: Counting objects: 100% (35/35), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 7200 (delta 19), reused 20 (delta 10), pack-reused 7165
Receiving objects: 100% (7200/7200), 989.45 KiB | 990.00 KiB/s, done.
Resolving deltas: 100% (4989/4989), done.
~
/opt/anyenv/envs/phpenv/plugins ~
Cloning https://github.com/ngyuki/phpenv-composer master to phpenv-composer...
Cloning into 'phpenv-composer'...
remote: Enumerating objects: 60, done.
remote: Total 60 (delta 0), reused 0 (delta 0), pack-reused 60
Unpacking objects: 100% (60/60), done.
~
Install phpenv succeeded!
Please reload your profile (exec $SHELL -l) or open a new session.
成功しました。
以下を実行して確認します。
$ exec $SHELL -l
$ which phpenv
/opt/anyenv/envs/phpenv/bin/phpenv
5.5.2. phpのインストール
では、phpのインストールを実施します。
まずはインストールするバージョンを確認します。
$ phpenv install --list
今回は、最新版である7.3.9
と5系の最新版である5.6.40
をインストールします。
$ php install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Downloading]: https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: ).
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
configure: error: Cannot find OpenSSL's <evp.h>
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908022546.log'.
[Warn]: Aborting build.
エラーが出ました。
re2cのバージョンがサポートされてないということなので、Homebrewからre2cをインストールしてみます。
$ brew install re2c
==> Downloading https://homebrew.bintray.com/bottles/re2c-1.2.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/2d/2d9f14907212e68580afa38eae450c8c0a9157169a1fd00e6faf27f872134433?__gda__=exp=15678781
######################################################################## 100.0%
==> Pouring re2c-1.2.1.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/re2c/1.2.1: 7 files, 675.0KB
これでもう一度phpのインストールを試みましょう。
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: ).
configure: error: Cannot find OpenSSL's <evp.h>
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908023153.log'.
[Warn]: Aborting build.
メッセージが減りました。
このようにしてパッケージを追加しつつインストールを進めます。
次はbisonです。
$ brew install bison
$ brew install bison
==> Downloading https://homebrew.bintray.com/bottles/bison-3.4.1.mojave.bottle.tar.gz
Already downloaded: /Users/takerulocal/Library/Caches/Homebrew/downloads/dc40c484c699b616a3bc7ed4a5b2037331458225767a8cbcd4c5152e6ea5fbcc--bison-3.4.1.mojave.bottle.tar.gz
==> Pouring bison-3.4.1.mojave.bottle.tar.gz
==> Caveats
bison is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of bison.
If you need to have bison first in your PATH run:
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
For compilers to find bison you may need to set:
export LDFLAGS="-L/usr/local/opt/bison/lib"
==> Summary
🍺 /usr/local/Cellar/bison/3.4.1: 85 files, 2.6MB
$ which bison
/usr/bin/bison
bisonをインストールしましたが、Homebrewのパッケージをみてくれません。
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/opt/anyenv/envs/pyenv/shims/icu-config
/opt/anyenv/envs/pyenv/shims/krb5-config
/opt/anyenv/envs/pyenv/shims/libpng16-config
/opt/anyenv/envs/pyenv/shims/python3.7-config
/opt/anyenv/envs/pyenv/shims/python3.7m-config
/opt/anyenv/envs/pyenv/shims/python-config
/opt/anyenv/envs/pyenv/shims/python3-config
/opt/anyenv/envs/pyenv/shims/ncursesw6-config
/opt/anyenv/envs/pyenv/shims/pcre-config
Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so:
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
configスクリプト関係とpyenv関係は、Homebrewとは別にインストールしているので仕方ないとして、sbinのPATHが通っていないことを指摘されているので以下のコマンドを実行します。
$ echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ exec $SHELL -l
さらに、evp.hがないと言われていることに対する対処です。
Homebrewでlibxml2をインストールします。
$ brew install libxml2
==> Installing dependencies for libxml2: gdbm, readline, sqlite, xz and python
==> Installing libxml2 dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.mojave.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.18.1.mojave.bottle.1.tar.gz
🍺 /usr/local/Cellar/gdbm/1.18.1: 20 files, 586.8KB
==> Installing libxml2 dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-8.0.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3c/3c754391e9d243835811d128771ca0f1a565024100fd2c2871534353d46aaf0e?__gda__=exp=15678795
######################################################################## 100.0%
==> Pouring readline-8.0.1.mojave.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
For compilers to find readline you may need to set:
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
==> Summary
🍺 /usr/local/Cellar/readline/8.0.1: 48 files, 1.5MB
==> Installing libxml2 dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.29.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/5f/5f2f8f36a8d13733b0374ac39bdcd32dea10315e7442b9bb9942465487cb7811?__gda__=exp=15678795
######################################################################## 100.0%
==> Pouring sqlite-3.29.0.mojave.bottle.tar.gz
==> Caveats
sqlite is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.
If you need to have sqlite first in your PATH run:
echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile
For compilers to find sqlite you may need to set:
export LDFLAGS="-L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include"
==> Summary
🍺 /usr/local/Cellar/sqlite/3.29.0: 11 files, 3.9MB
==> Installing libxml2 dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/01/010667293df282c8bceede3bcd36953dd57c56cef608d09a5b50694ab7d4b96b?__gda__=exp=15678795
######################################################################## 100.0%
==> Pouring xz-5.2.4.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/xz/5.2.4: 92 files, 1MB
==> Installing libxml2 dependency: python
==> Downloading https://homebrew.bintray.com/bottles/python-3.7.4.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/81/81fc6e5914a16387bd09387ce08e99122ea3ad65c55ded42ea07f40952aa20d1?__gda__=exp=15678795
######################################################################## 100.0%
==> Pouring python-3.7.4.mojave.bottle.tar.gz
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/p
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/p
==> /usr/local/Cellar/python/3.7.4/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/p
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python@2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
🍺 /usr/local/Cellar/python/3.7.4: 3,865 files, 60MB
==> Installing libxml2
==> Downloading https://homebrew.bintray.com/bottles/libxml2-2.9.9_2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/1e/1e6143e9bfb756fe80e4a1db417b722569429a815365ed9070556e81bd2db02a?__gda__=exp=15678795
######################################################################## 100.0%
==> Pouring libxml2-2.9.9_2.mojave.bottle.tar.gz
==> Caveats
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
For compilers to find libxml2 you may need to set:
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
==> Summary
🍺 /usr/local/Cellar/libxml2/2.9.9_2: 281 files, 10.5MB
==> Caveats
==> readline
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.
For compilers to find readline you may need to set:
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
==> sqlite
sqlite is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.
If you need to have sqlite first in your PATH run:
echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile
For compilers to find sqlite you may need to set:
export LDFLAGS="-L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include"
==> python
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python@2
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
==> libxml2
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have libxml2 first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
For compilers to find libxml2 you may need to set:
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"
これで再度phpのインストールを試みる。
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: error: Cannot find zlib
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908025439.log'.
[Warn]: Aborting build.
一難去ってまた一難。。。
今度はzlibをインストールする。
$ brew install zlib
==> Downloading https://homebrew.bintray.com/bottles/zlib-1.2.11.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring zlib-1.2.11.mojave.bottle.tar.gz
==> Caveats
zlib is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
For compilers to find zlib you may need to set:
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
==> Summary
🍺 /usr/local/Cellar/zlib/1.2.11: 12 files, 373KB
これでも失敗します。。。
zlibの失敗は、参考記事にも書かれていますがMojaveの場合、macOS SDK headerがないらしいです。
以下のコマンドでヘッダーをインストールします。
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
installer: Package name is macOS_SDK_headers_for_macOS_10.14
installer: Installing at base path /
installer: The install was successful.
これで再度インストールを試みます。
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: WARNING: Fallback: search for curl headers and curl-config
configure: error: jpeglib.h not found.
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908030849.log'.
[Warn]: Aborting build.
次に進みました。。。
次はjpeglib.hと出ています。
libjpeg
をインストールします。
$ brew install libjpeg
==> Downloading https://homebrew.bintray.com/bottles/jpeg-9c.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/1d/1daa0fc0c197d96dd4e1afddb9ad576951a15aafd6b85138b8a60817d1d8173c?__gda__=exp=15678805
######################################################################## 100.0%
==> Pouring jpeg-9c.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/jpeg/9c: 21 files, 733.4KB
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: WARNING: Fallback: search for curl headers and curl-config
configure: error: png.h not found.
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908031303.log'.
[Warn]: Aborting build.
今度はpng.hですね。。。libpng
をインストールします。
$ brew install libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.37.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/53/53bbd14cc27c86c16605e256e7646a1b5656c253abca084958c5d80a2961cb01?__gda__=exp=15678807
######################################################################## 100.0%
==> Pouring libpng-1.6.37.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/libpng/1.6.37: 27 files, 1.2MB
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
configure: WARNING: Fallback: search for curl headers and curl-config
configure: error: Please reinstall the libzip distribution
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908031438.log'.
[Warn]: Aborting build.
今度はlibzipですね。
$ brew install libzip
==> Downloading https://homebrew.bintray.com/bottles/libzip-1.5.2.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libzip-1.5.2.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/libzip/1.5.2: 134 files, 579.6KB
いよいよコンパイルまで進む。。。
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
[Compiling]: /var/tmp/php-build/source/7.3.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
__php_iconv_strlen in iconv.o
_zif_iconv_substr in iconv.o
__php_iconv_strpos in iconv.o
_zif_iconv_mime_encode in iconv.o
__php_iconv_mime_decode in iconv.o
_php_iconv_stream_filter_factory_create in iconv.o
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [sapi/cli/php] Error 1
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908031645.log'.
[Warn]: Aborting build.
今度はiconvです。。。
以下の情報があるようです。
configure_optionの設定を
configure_option "--with-iconv=shared,/usr"
として解決。
configure_optionは
/usr/local/Cellar/php-build//share/php-build/definitions/
の一番最初に記述
これを基に以下のファイルを変更します。
vim /opt/anyenv/envs/phpenv/plugins/php-build/share/php-build/definitions/7.3.9:
configure_option "--with-iconv=shared,/usr"
を先頭に追加
再度チャレンジ。
$ phpenv install 7.3.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
[Compiling]: /var/tmp/php-build/source/7.3.9
[xdebug]: Installing version 2.7.2
[Downloading]: http://xdebug.org/files/xdebug-2.7.2.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.7.2
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/signal.h:106:48: note: insert '_Nullable' if the pointer may be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/signal.h:106:48: note: insert '_Nonnull' if the pointer should never be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nonnull
211 warnings generated.
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
-----------------------------------------
The full Log is available at '/tmp/php-build.7.3.9.20190908033159.log'.
[Warn]: Aborting build.
色々調べましたが、以下のパッケージのインストールが必要なようです。
$ brew install autoconf automake
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.mojave.bottle.4.tar.gz
==> Downloading from https://akamai.bintray.com/97/9724736d34773b6e41e2434ffa28fe79feccccf7b7786e54671441ca75115cdb?__gda__=exp=15679025
######################################################################## 100.0%
==> Pouring autoconf-2.69.mojave.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/autoconf
==> Summary
🍺 /usr/local/Cellar/autoconf/2.69: 71 files, 3.0MB
==> Downloading https://homebrew.bintray.com/bottles/automake-1.16.1_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/0a/0a359c2385d0673ce1ab3cdaf39dd22af191f7b74732105ca5751e08a334e061?__gda__=exp=15679025
######################################################################## 100.0%
==> Pouring automake-1.16.1_1.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/automake/1.16.1_1: 131 files, 3.4MB
==> Caveats
==> autoconf
Emacs Lisp files have been installed to:
/usr/local/share/emacs/site-lisp/autoconf
再度インストール。
$ phpenv install 7.3.9
phpenv: /opt/anyenv/envs/phpenv/versions/7.3.9 already exists
continue with installation? (y/N) y
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
[Compiling]: /var/tmp/php-build/source/7.3.9
[xdebug]: Installing version 2.7.2
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-2.7.2.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.7.2
[xdebug]: Installing xdebug configuration in /opt/anyenv/envs/phpenv/versions/7.3.9/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.3.9.20190908091732.log or rebuild with '--verbose' option
[Success]: Built 7.3.9 successfully.
やっと成功しました。。。
$ phpenv versions
* system (set by /opt/anyenv/envs/phpenv/version)
7.3.9
$ phpenv global 7.3.9
7.3.9
$ phpenv versions
system
* 7.3.9 (set by /opt/anyenv/envs/phpenv/version)
tobby2:~ takerulocal$ php -version
PHP 7.3.9 (cli) (built: Sep 8 2019 09:27:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.9, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
適用できました。
ここで、5.6.40もインストールしたいと思います。
以下のファイルに追記します。
(5.6.40のインストールは後日説明します。)
5.5.3. htmlとの連携に必要なmoduleの切り替えについて
phpのhtml用module生成には、apacheのインストールが必要になります。
Homebrewでapacheをインストールします。
$ brew install httpd
==> Installing dependencies for httpd: apr, apr-util, brotli, c-ares, jansson, jemalloc, libev, libevent, nghttp2 and pcre
==> Installing httpd dependency: apr
==> Downloading https://homebrew.bintray.com/bottles/apr-1.7.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3a/3a245185ed7280d1a19e7c639786b4c21dd0088878be8ac87ca58510eb5c9cc1?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring apr-1.7.0.mojave.bottle.tar.gz
==> Caveats
apr is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.
If you need to have apr first in your PATH run:
echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.bash_profile
==> Summary
🍺 /usr/local/Cellar/apr/1.7.0: 59 files, 1.4MB
==> Installing httpd dependency: apr-util
==> Downloading https://homebrew.bintray.com/bottles/apr-util-1.6.1_1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e4/e4927892e16a3c9cf0d037c1777a6e5728fef2f5abfbc0af3d0d444e9d6a1d2b?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring apr-util-1.6.1_1.mojave.bottle.tar.gz
==> Caveats
apr-util is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.
If you need to have apr-util first in your PATH run:
echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.bash_profile
==> Summary
🍺 /usr/local/Cellar/apr-util/1.6.1_1: 54 files, 777.5KB
==> Installing httpd dependency: brotli
==> Downloading https://homebrew.bintray.com/bottles/brotli-1.0.7.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/d2/d2d4f821f8d9c52de15a4d3b5ddeab760ad9ae71105f1c859b7811adff9af9da?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring brotli-1.0.7.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/brotli/1.0.7: 25 files, 2.2MB
==> Installing httpd dependency: c-ares
==> Downloading https://homebrew.bintray.com/bottles/c-ares-1.15.0.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring c-ares-1.15.0.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/c-ares/1.15.0: 72 files, 482.6KB
==> Installing httpd dependency: jansson
==> Downloading https://homebrew.bintray.com/bottles/jansson-2.12.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring jansson-2.12.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/jansson/2.12: 11 files, 157.5KB
==> Installing httpd dependency: jemalloc
==> Downloading https://homebrew.bintray.com/bottles/jemalloc-5.2.1.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/9f/9fbc2052929cedb26b55bf21d0ac539d8ec153d138fde9dbd57e8bf9ed943b81?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring jemalloc-5.2.1.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/jemalloc/5.2.1: 16 files, 1.9MB
==> Installing httpd dependency: libev
==> Downloading https://homebrew.bintray.com/bottles/libev-4.27.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libev-4.27.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/libev/4.27: 12 files, 438.6KB
==> Installing httpd dependency: libevent
==> Downloading https://homebrew.bintray.com/bottles/libevent-2.1.11.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/0a/0a8ab56e634a686654b83cfa5a94ea7a388bc19149372fceea54663cbad029f9?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring libevent-2.1.11.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/libevent/2.1.11: 1,063 files, 5MB
==> Installing httpd dependency: nghttp2
==> Downloading https://homebrew.bintray.com/bottles/nghttp2-1.39.2.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/6d/6d1d1e137cdb97927bb16ebdd26436b0ac7dfcb07bf8d095f1b122a2936113b2?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring nghttp2-1.39.2.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/nghttp2/1.39.2: 26 files, 2.6MB
==> Installing httpd dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.43.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/08/08e7414a7641d1e184c936537ff67f72f52649374d2308b896d4146ccc2c08fe?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring pcre-8.43.mojave.bottle.tar.gz
🍺 /usr/local/Cellar/pcre/8.43: 204 files, 5.5MB
==> Installing httpd
==> Downloading https://homebrew.bintray.com/bottles/httpd-2.4.41.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/69/69fa9c4f5ac1da302f5784353ca75fe9d20d09d62308f9dd12565c427c5bb7e1?__gda__=exp=15679178
######################################################################## 100.0%
==> Pouring httpd-2.4.41.mojave.bottle.tar.gz
==> Caveats
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To have launchd start httpd now and restart at login:
brew services start httpd
Or, if you don't want/need a background service you can just run:
apachectl start
==> Summary
🍺 /usr/local/Cellar/httpd/2.4.41: 1,652 files, 27.2MB
==> Caveats
==> apr
apr is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.
If you need to have apr first in your PATH run:
echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.bash_profile
==> apr-util
apr-util is keg-only, which means it was not symlinked into /usr/local,
because Apple's CLT package contains apr.
If you need to have apr-util first in your PATH run:
echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.bash_profile
==> httpd
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To have launchd start httpd now and restart at login:
brew services start httpd
Or, if you don't want/need a background service you can just run:
apachectl start
さらに以下のファイルを編集します。
$ vim /opt/anyenv/envs/phpenv/plugins/php-build/share/php-build/definitions/7.3.9
#以下を追加
configure_option "--with-openssl=/usr/local/opt/openssl"
configure_option "--with-iconv=shared,/usr"
configure_option "--with-apxs2=/usr/local/bin/apxs"
また、opensslがHomebrew側を見に行くようにコンパイル時に以下のようにします。
PATH="/usr/local/opt/openssl/bin:$PATH" phpenv install 7.3.9
phpenv: /opt/anyenv/envs/phpenv/versions/7.3.9 already exists
continue with installation? (y/N) y
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.3.9 into /opt/anyenv/envs/phpenv/versions/7.3.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.3.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.3.9
[Compiling]: /var/tmp/php-build/source/7.3.9
[xdebug]: Installing version 2.7.2
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-2.7.2.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.7.2
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.3.9.20190911213933.log or rebuild with '--verbose' option
[Success]: Built 7.3.9 successfully.
コンパイルが成功しました。
生成されたlibphp7.soをanyenvの中にコピーします。
$ cp /usr/local/opt/httpd/lib/httpd/modules/libphp7.so /opt/anyenv/envs/phpenv/versions/7.3.9/
次に、apacheモジュールの切り替えに必要なプラグイン "pheenv-apache-version"をインストールします。
$ git clone https://github.com/garamon/phpenv-apache-version /opt/anyenv/envs/phpenv/plugins/phpenv-apache-version
Cloning into '/opt/anyenv/envs/phpenv/plugins/phpenv-apache-version'...
remote: Enumerating objects: 41, done.
remote: Total 41 (delta 0), reused 0 (delta 0), pack-reused 41
Unpacking objects: 100% (41/41), done.
切り替えコマンドを実行してみましょう。
$ phpenv apache-version 7.3.9
phpenv: no such command `apache-version'
現時点でコマンドがないと言われてしまう状況です。
これについては後日調査しようと思います。
6. さいごに
今回、anyenvで様々な**env系のインストールを行いました。予想通り、phpenvに苦戦しています。しかしながら、WordPressをはじめとする世のCMSのほとんどはphpを用いていることから、phpは未だ必要不可欠です。
私もphpをもっと勉強したいと思います。
7. 参考サイト
7.1. anyenvインストール関係
7.2. phpenvを用いたインストール関係
- Macのphpenv(php-build)でビルドしようとしたら出るエラーと解決まとめ - Qiita
- PHPのインストールでエラー – LOG
- phpenv+php-build環境によるphpバージョン管理~Mac(Yosemite)編~ - Qiita
- phpenvでphpをインストールしている時にopensslエラーが出る場合の解決メモ - Qiita
- phpenvのコマンドとphpenv-apache-versionの切り替えコマンド - Qiita
- phpenvによるApacheのphpモジュールを切り替え – phpenvで Apacheのphpモジュールを切り替えるプラグインつくった | Creator Life
- mac php環境構築 · GitHub