最近PHPをビルドし直したりしてたのでメモ。
インストールオプションの指定
default_configuration_options
やdefinitions
での指定は行わず、CONFIGURE_OPTS
に設定してインストールするようにした。
postgresqlとintl,apcuを有効にしてインストールしています。
$ anyenv update
$ CONFIGURE_OPTS="--with-pgsql=$(brew --prefix postgresql) --with-pdo-pgsql=$(brew --prefix postgresql) --enable-intl --enable-apcu" phpenv install 7.2.9
今まではバージョンごとにdefinitions
に定義していたけど、anyenv updateしたときにコンフリクトする時があるのと、毎回追加するのが面倒になってきたので。
iniファイルの設置
php.ini
date.timezone = Asia/Tokyo
memory_limit = -1
を毎回書いているので、after-install.d
で放り込むようにした。
以下のようなシェルを、~/.anyenv/envs/phpenv/plugins/php-build/share/php-build/after-install.d
においておくと、インストール完了後に実行してくれる。
create_custom_ini.sh
#!/usr/bin/env bash
echo "date.timezone = Asia/Tokyo" > $PREFIX/etc/conf.d/custom.ini
echo "memory_limit = -1" >> $PREFIX/etc/conf.d/custom.ini
実行されると、After Install Trigger
みたいなログがでてきます。
[xdebug] : Cleaning up.
[Info] : Enabling Opcache...
[Info] : Done
[After Install Trigger] : create_custom_ini.sh
[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.1.4.20170420184805.log
[Success] : Built 7.1.4 successfully.
参考
以下が非常に参考になりました。ありがとうございます。
- phpenvのPHPインストール時のオプションメモ
- php-build をカスタマイズして使う - y_uti のブログ