CentOS7.5にanyenvとphpenvでPHP7.2を入れようとした際のエラーと対処まとめ

スポンサーリンク

新しいVPSにanyenvからphpenvを入れようとしたら色々なエラーが出たのでそれぞれの対処メモを残しておきます。phpビルドの話なのでanyenvはあんまり関係ありません。

yum installするパッケージまとめ

以下の各項目で必要なパッケージのまとめです。

$ sudo yum install bzip2 bzip2-devel bison re2c libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel readline-devel libtidy-devel libxslt-devel

色々なエラー

tar (child): bzip2: exec 不能: そのようなファイルやディレクトリはありません

$ sudo yum install bzip2

./buildconf: そのようなファイルやディレクトリはありません

/home/***/.anyenv/envs/phpenv/plugins/php-build/bin/php-build: 行 548: ./buildconf: そのようなファイルやディレクトリはありません

上のbzip2を入れてphpenv installをやり直したらなんか謎にこんなエラーが出て止まるようになりました

詳細はよくわからないですがキャッシュ的な何かの問題らしく、/tmp/php-build を削除してやり直したら出なくなりました。

rm -rf /tmp/php-build

参考:./buildconf: No such file or directory · Issue #80 · phpenv/phpenv

configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).

$ sudo yum install bison

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

$ sudo yum install re2c

configure: error: xml2-config not found. Please check your libxml2 installation.

$ sudo yum install bison re2c libxml2-devel

configure: WARNING: unrecognized options: –with-mcrypt

phpenvが7.2に無いビルドオプションを指定しているというだけで実害は無いので無視しても良さそう。
気になる場合は
.anyenv/envs/phpenv/plugins/php-build/share/php-build/default_configure_options
から–with-mcryptを削除。

configure: error: Cannot find OpenSSL’s <evp.h>

$ sudo yum install openssl-devel

configure: error: Please reinstall the BZip2 distribution

$ sudo yum install bzip2-devel

configure: error: cURL version 7.10.5 or later is required to compile php with cURL support

$ sudo yum install libcurl-devel

configure: error: jpeglib.h not found.

$ sudo yum install libjpeg-devel

configure: error: png.h not found.

$ sudo yum install libpng-devel

configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.

$ sudo yum install libicu-devel

configure: error: Please reinstall readline – I cannot find readline.h

$ sudo yum install readline-devel

configure: error: Cannot find libtidy

$ sudo yum install libtidy-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

$ sudo yum install libxslt-devel

configure: WARNING: Use of bundled libzip is deprecated and will be removed.

全文:

configure: WARNING: ========================================================
configure: WARNING: Use of bundled libzip is deprecated and will be removed.
configure: WARNING: Some features such as encryption and bzip2 are not available.
configure: WARNING: Use system library and --with-libzip is recommended.
configure: WARNING: ========================================================

libzip-develを入れて前述のdefault_configure_optionsに–with-libzipを追加したところ
configure: error: system libzip must be upgraded to version >= 0.11
とCentOSリポジトリの最新なのにlibzipが古すぎると言われ、めんどくさそうなので放置しました。WARNINGだし…。

WARNINGしかない、もしくはWARNINGすら無くビルドログも空なのにBUILD ERRORになる

phpenv install -v 7.2.10 でmakeの出力を確認したところ、VPSのメモリが少ないためメモリ不足でエラーになっていました。

virtual memory exhausted: メモリを確保できません
cc: コンパイラ内部エラー: 強制終了 (プログラム cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make: *** [ext/fileinfo/libmagic/apprentice.lo] エラー 1

ファイルシステム上にスワップファイルを作成してメモリ不足を補います。とりあえず1Gのスワップファイルを作成します。
参考:How To Add Swap on CentOS 7 | DigitalOcean

$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
スワップ空間バージョン1を設定します、サイズ = 1048572 KiB
ラベルはありません, UUID=9eb6795d-43a4-4400-86e8-1b0ee835aee2
$ sudo swapon /swapfile

確認

swapon -s
Filename                                Type            Size    Used    Priority
/swapfile                               file    1048572 0       -1

これでビルド通りました!

ちなみに作成したスワップファイルを削除する場合は

$ sudo swapoff /swapfile
$ sudo rm /swapfile

でとするようです。(fstabを記入した場合はそれも消す)

コメント

タイトルとURLをコピーしました