ペチゾーが来たゾウ🐘
ラズパイ(CentOS)にphpbrewで最新版のPHPをinstallしてみる。
phpcon2021でペチゾー君が我が家に来たので久々にPHP触ってBenchmarkとってみようと思い立ったのでやってみる。
こういう抽選系のは当たったことないのでうれしい。elePHPantも欲しいです。
ちなみに PHP5.6系&CakePHP2なアプリケーション開発はしたことあります。確か4年ぐらい前の話。
プライベートでLalavel使ってメモ帳的なものも作ったことあるけど忘れてしまった。
$ dnf install php $ curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew $ mv phpbrew /usr/local/bin/ $ /usr/local/bin/phpbrew init $vi ~/.bashrc ## 追記 [[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc $ phpbrew known # WARNING: json extension is required for parsing release info. ===> Fetching release list... Downloading https://www.php.net/releases/index.php?json=1&version=8&max=100 via curl extension PHP Fatal error: Uncaught Error: Call to undefined function PhpBrew\json_decode() in phar:///usr/local/bin/phpbrew/src/PhpBrew/ReleaseList.php:171 Stack trace: #0 phar:///usr/local/bin/phpbrew/src/PhpBrew/ReleaseList.php(177): PhpBrew\ReleaseList::downloadReleaseListFromOfficialSite(8, 100, Object(GetOptionKit\OptionResult)) #1 phar:///usr/local/bin/phpbrew/src/PhpBrew/ReleaseList.php(136): PhpBrew\ReleaseList::buildReleaseListFromOfficialSite(Object(GetOptionKit\OptionResult)) #2 phar:///usr/local/bin/phpbrew/src/PhpBrew/Tasks/FetchReleaseListTask.php(13): PhpBrew\ReleaseList->fetchRemoteReleaseList(Object(GetOptionKit\OptionResult)) #3 phar:///usr/local/bin/phpbrew/src/PhpBrew/Command/KnownCommand.php(39): PhpBrew\Tasks\FetchReleaseListTask->fetch() #4 [internal function]: PhpBrew\Command\KnownCommand->execute() #5 phar:///usr/local/bin/phpbrew/vendor/corneltek/cliframework/src/CommandBase.php(846): call_user_func_array(Array, Array) #6 phar:///usr/local/bin/phpbrew/vendor/corneltek/cliframework/src/Application.php(398): CL in phar:///usr/local/bin/phpbrew/src/PhpBrew/ReleaseList.php on line 171 ## jsonモジュールがないだけみたいなのでinstall $ dnf install php-json $ phpbrew known ===> Fetching release list... Downloading https://www.php.net/releases/index.php?json=1&version=8&max=100 via curl extension Downloading https://www.php.net/releases/index.php?json=1&version=7&max=100 via curl extension 8.0: 8.0.11, 8.0.10, 8.0.9, 8.0.8, 8.0.7, 8.0.6, 8.0.5, 8.0.3 ... 7.4: 7.4.24, 7.4.23, 7.4.22, 7.4.21, 7.4.20, 7.4.19, 7.4.18, 7.4.16 ... 7.3: 7.3.31, 7.3.30, 7.3.29, 7.3.28, 7.3.27, 7.3.26, 7.3.25, 7.3.24 ... 7.2: 7.2.34, 7.2.33, 7.2.32, 7.2.31, 7.2.30, 7.2.29, 7.2.28, 7.2.27 ... 7.1: 7.1.33, 7.1.32, 7.1.31, 7.1.30, 7.1.29, 7.1.28, 7.1.27, 7.1.26 ... ## phpbrewで見える最新のものをinstall $ phpbrew install 8.0.11 +default ## error出る Package 'libxml-2.0', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBXML_CFLAGS and LIBXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. ## 言われたとおりに ## see https://centos.pkgs.org/8/okey-x86_64/libxml2-devel-2.9.7-5.el8.x86_64.rpm.html $ dnf install libxml2-devel ## またerror checking for zlib >= 1.2.0.4... yes checking whether to enable bc style precision math functions... yes checking for BZip2 support... yes checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution Please checkout the build log file for more details: ## see https://centos.pkgs.org/8/centos-baseos-x86_64/bzip2-devel-1.0.6-26.el8.x86_64.rpm.html $ dnf install bzip2-devel ## 次のerror and CURL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. Please checkout the build log file for more details: tail /root/.phpbrew/build/php-8.0.11/build.log [root@localhost ~]# tail /root/.phpbrew/build/php-8.0.11/build.log configure: error: Package requirements (libcurl >= 7.29.0) were not met: Package 'libcurl', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables CURL_CFLAGS and CURL_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. ## see https://centos.pkgs.org/8-stream/centos-baseos-x86_64/libcurl-devel-7.61.1-18.el8.x86_64.rpm.html $ dnf install libcurl-devel ....
このあとも onigurumaがないとか色々と怒られたけど割愛。dnf install していくだけ。
ちゃんとしたやり方あるはずなんだけど見切り発車でやってしまったので結構詰まった。絶対スマートなやり方ある。
↓に必要だったものをまとめておきます。
$ dnf install php-json libxml2-devel bzip2-devel libcurl-devel readline-devel oniguruma-devel libxslt-devel libzip-devel
これで完了です。
Congratulations! Now you have PHP with 8.0.11 as php-8.0.11 * To configure your installed PHP further, you can edit the config file at /root/.phpbrew/php/php-8.0.11/etc/php.ini To use the newly built PHP, try the line(s) below: $ phpbrew use php-8.0.11 Or you can use switch command to switch your default php to php-8.0.11: $ phpbrew switch php-8.0.11
PHP8からJITが導入されて爆速化しているみたいですね。
PRみましたが、相当な量で追うのを諦めました。というよりも知識が追いついていない感。
Benchmarkには以下を使う予定