$30 off During Our Annual Pro Sale. View Details »

Crafting a Own PHP - ウキウキ手作りミニマリストPHP

uzulla
March 08, 2024

Crafting a Own PHP - ウキウキ手作りミニマリストPHP

at: PHPerKaigi 2024
date: 2024/3/8(sat)
speaker: uzulla

(以下AIによるサマリ)
このプレゼンテーションは、PHPのカスタムビルドに関するもので、PHPバイナリの作成方法、拡張モジュールの管理、php.iniの設定変更方法などを説明しています。また、PHPのビルドオプション、依存ライブラリの指定、静的と動的モジュールの違い、そして自前でパッケージを作成する方法についても触れています。さまざまなPHP環境の構築方法とその思想についても言及されており、PHPの深い理解と実践的なカスタマイズ方法を提供しています。

uzulla

March 08, 2024
Tweet

More Decks by uzulla

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ { JEV[VMMB 9 (JU)VC :PVUVCF FUDʜ { ৭ʑͰੜܭ Λཱ͍ͯͯ·͢

    { ϊϕϧςΟ੡࡞ͨ͠Γʜ { 1.&.ͨ͠Γʜ { :PVUVCF ൪એಈը ࡱͬͨΓʜ νϟϯωϧొ࿥͕ݴ͑ͳ͍உͰ͢ { ·͋Ͱ΋ɺຊۀ͸1)1ؔ܎Ͱ͢
  2. օ͞Μɺ1)1όΠφϦΛͲ͔͜Βʁ { 1)1͸$ݴޠͰॻ͔Ε͍ͯ·͢ Ϗϧυ ίϯύΠϧ ͢Δ͜ͱͰɺ1)1όΠφϦ͕Ͱ͖·͢ { ਅ৺ࠐΊͨख࡞ΓͷϏϧυ configure; make

    all; make install { ۙ೥ϨΞɺͳͥͳΒόΠφϦΛ৭ʑͳॴ͔ΒೖखPS࡞੒Ͱ͖Δ͔Β { %PDLFSͱ͔ɺCSFXͱ͔ɺBQUͱ͔ɺZVNͱ͔ɺQIQFOWͱ͔ɺBTEGͱ ͔ { Ͱ΋ɺϏϧυํ๏Λ஌͓ͬͯ͘ͱศརͳ͜ͱ͕͋Δ͔΋͠Εͳ͍ʂ
  3. ͱΓ͋͑ͣɺ࠷଎Ͱ1)1ͷϏϧυମݧͯ͠ΈΑ͏ʂ { -JOVY%PDLFSͰ࠷଎ͰϚΠ1)1ͷϏϧυΛ΍ͬͯΈΔ { ஫ݱࡏͷख๏Ͱ͢ɺมΘ͍ͬͯΔՄೳੑ͕͋Γ·͢ $ docker run --rm -it

    ubuntu:latest /bin/bash { ͜ΕͰɺ6CVOUVͷ࢖͍ࣺͯίϯςφ্ཱ͕͕ͪΓ·͢ SNΦϓγϣϯΛ͚͓ͭͯΓɺऴྃ͢Δͱফ͑·͢ɺ΍Γ௚͠ʹ࠷ ద
  4. 1)1ͷϏϧυखॱ apt update apt install -y git pkg-config build-essential \

    autoconf bison re2c libxml2-dev libsqlite3-dev git clone --depth 1 https://github.com/php/php-src.git cd php-src ./buildconf ./configure make -j10 make install { ؆୯Ͱ͢Ͷʁ ࣮༻ʹ͸΋͏ͪΐͬͱෳࡶͰ͕͢ޙड़
  5. ςετ { Ͱ͖ͨ1)1Λ࢖ͬͯΈ·͠ΐ͏ $ php -v PHP 8.4.0-dev (cli) (built:

    Mar 1 2024 13:08:18) (NTS) Copyright (c) The PHP Group Zend Engine v4.4.0-dev, Copyright (c) Zend Technologies $ which php /usr/local/bin/php
  6. ͳ͔ͥʁ { ͜Ε͸ɺϏϧυ࣌ʹreadlineϞδϡʔϧ͕ઃఆ͞Ε͍ͯͳ͔͔ͬͨΒ Ͱ͢ { php-srcʹ͋Δ./configure -hͰΦϓγϣϯΛݟͯΈ·͠ΐ͏ ./configure --help |

    less ͋Δ͍͸ ./configure --help | grep readline (লུ) --with-readline[=DIR] Include readline support (CLI/CGI only)
  7. Ϗϧυ͠௚ͯ͠ΈΔ { --with-readlineΛ͚ͭͯϏϧυ͠௚ͯ͠Έ·͠ΐ͏ ./configure --with-readline (লུ) checking for readline support...

    yes configure: error: Please reinstall readline - I cannot find readline.h { ͳΜ͔Τϥʔ͕ग़ͯ͠·͍·ͨ͠Ͷʜ { 1)1Λख࡞Γ͖ͯͨ͠ຽ͸ճ͸ݟͨΤϥʔͰ͢Ͷ
  8. ϥΠϒϥϦ ˍϔομʔϑΝΠϧ ͕ඞཁ { ඞཁͳϥΠϒϥϦΛผ్ೖΕΔඞཁ͕͋Γ·͢ɺ BQUͩͱlibreadline-devͰ͢ apt install -y libreadline-dev

    ./configure --with-readline { ˞ࠓ౓͸੒ޭ͢Δ͸ͣ { ˞ϥΠϒϥϦ໊ͦͷ··Ͱͳ͘ɺ *-devͱ͍͏ͷ͕େମඞཁͳͷ͸͓͖֮͑ͯ·͠ΐ͏
  9. $ apt-file search readline.h |grep -e "/readline.h$" gnulib: /usr/share/gnulib/lib/readline.h guile-2.2-dev:

    /usr/include/guile/2.2/readline.h guile-3.0-dev: /usr/include/guile/3.0/readline.h libedit-dev: /usr/include/editline/readline.h libreadline-dev: /usr/include/readline/readline.h ^--ύοέʔδ໊ ^--ϑΝΠϧ໊
  10. ͱ͍͏͜ͱͰɺϏϧυͷయܕྫΛ·ͱΊΔͱʜ { configure -hͰඞཁͳΦϓγϣϯΛ୳͢ { configureΛ͢Δ { ඞཁͳΒґଘϥΠϒϥϦΛೖΕΔ { make;

    make install͢Δ Τϥʔ͕ग़ͨΒάάΔ { ଞʹ΋͍Ζ͍ΖΦϓγϣϯ͕͋Γ·͕͢ɺجຊ͸͜ΕͰ͢ { 3&"%.&NE ΍*/45"--NE ΛΈ·͠ΐ͏ { ඞཁͳϞδϡʔϧΛ௥Ճ͠ɺʮ࠷ڧͷ1)1ʯΛ࡞Ζ͏ͳʂ
  11. ׬

  12. ΠϯετʔϧઌΛมߋͯ͠ΈΔํ๏ { σϑΥϧτ͸make installͰ/usr/localʹೖΔ { ʮ্ॻ͖ͪ͠Ό͏ʁʯʮͦΜͳ͜ͱ͸ͳ͍ɺ࣮͸ෳ਺JOTUBMMͰ͖Δʯ ./configure --prefix=/tmp/myphp make -j10

    make install $ /tmp/myphp/bin/php -v PHP 8.4.0-dev (cli) (built: Mar 1 2024 14:52:41) (NTS) { QSFpY͸configureͷఆ൪ͳͷͰɺ͓͖֮͑ͯ·͠ΐ͏
  13. ݁ہmake install͢Δͱͳʹ͕͸͍Δͷʁ { QSFpY͚ͭͨΒQIQͷϑΝΠϧ͔͠ͳ͍%JS͕Ͱ͖ΔͷͰɺ ௐ΂ΒΕ·͢Ͷ $ cd /tmp/myphp $ find

    . -maxdepth 1 ./php = manίϚϯυͷϑΝΠϧ ./bin = όΠφϦ܈ ./lib = γΣΞυϥΠϒϥϦ܈౳ ./include = ϔομϑΝΠϧ ./var = logͱ͔ { ੋඇɺօ͞Μࣗ෼ͰΈͯΈ·͠ΐ͏ { ࣮࣭ɺCJOͱMJC͕ॏཁͰɺ΄͔͸ෆཁͳࣄ΋ଟ͍Ͱ͢
  14. php.ini͸σϑΥϧτͰೖΒͳ͍ʂ bin/php --ini Configuration File (php.ini) Path: /tmp/myphp/lib Loaded Configuration

    File: (none) <== ϩʔυ͞Εͯͳ͍ Scan for additional .ini files in: (none) Additional .ini files parsed: (none) { php.ini-developmentphp.ini-productionͳͲΛ /tmp/myphp/lib/php.iniʹίϐʔ͠·͢ { ʮͳΜͰFUD͡Όͳͯ͘MJCͳͷʁʯʮݹདྷ͔Βͦ͏͔ͩΒʯ { ଟ͘͸--with-config-file-pathͰมߋͯ͠·͢Ͷ
  15. ଞʹ΋ɺ͍ΖΜͳEJSࢦఆ͕Ͱ͖Δ { prefixͰ·Δ͝ͱࢦఆͤͣɺࡉ͔͘ࢦఆ͢Δ͜ͱ΋ग़དྷ·͢ { php.iniͷ৔ॴͱ͔ɺ֦ுϞδϡʔϧϑΝΠϧͷ৔ॴͱ͔ʜ Ͱ΋ɺׂѪ͠·͢ɺ௕͍ͷͰ ਅإ ࣗ෼ͰݟͯΈΑ͏ʂ $ ./configure

    --help (ུ) --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] (20 ݸ͘Β͍͋Δ)
  16. ༨ஊ#SFXͱ͔΋͜͏͍͏࢓૊Έ $ /opt/homebrew/Cellar/php/8.3.3_1/bin/php -v PHP 8.3.3 (cli) (built: Feb 13

    2024 15:41:14) (NTS) {ུ} $ /opt/homebrew/Cellar/[email protected]/8.1.27_1/bin/php -v PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS) {ུ} $ /opt/homebrew/Cellar/[email protected]/8.2.16_1/bin/php -v PHP 8.2.16 (cli) (built: Feb 13 2024 15:22:59) (NTS) {ུ} { ͜ΕΒΛ4ZNMJOLͯ͠1BUIΛ௨͍ͯ͠Δ
  17. ʮ֦ுϞδϡʔϧʯͷ࿩ { 1)1ʹ͸͍ΖΜͳϞδϡʔϧ͕͋Γ·͢ɺSFBEMJOFͱ͔΋ͦ͏ { php -mͰ֬ೝͰ͖·͢ ͳ͓ɺphp.ini΋Өڹ͠·͢ ࢦఆͳ͠configureϏϧυͷphp) $ php

    -m [PHP Modules] Core, ctype, date, dom, fileinfo, filter, hash, iconv, json, libxml, pcre, PDO, pdo_sqlite, Phar, posix, random, Reflection, session, SimpleXML, SPL, sqlite3, standard, tokenizer, xml, xmlreader, xmlwriter [Zend Modules]
  18. MEE ϦϯΫݟΔ܅ ͰΈΔͱґଘ͕ଟ͍Ͱ͢Ͷ ޙड़͠·͢ $ ldd ../myphp/bin/php linux-vdso.so.1 (0x0000ffffb19bd000) libm.so.6

    => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffffb06c0000) libxml2.so.2 => /lib/aarch64-linux-gnu/libxml2.so.2 (0x0000ffffb04d0000) libsqlite3.so.0 => /lib/aarch64-linux-gnu/libsqlite3.so.0 (0x0000ffffb0370000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffffb01c0000) /lib/ld-linux-aarch64.so.1 (0x0000ffffb1984000) libicuuc.so.70 => /lib/aarch64-linux-gnu/libicuuc.so.70 (0x0000ffffaffb0000) libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000ffffaff80000) liblzma.so.5 => /lib/aarch64-linux-gnu/liblzma.so.5 (0x0000ffffaff40000) libicudata.so.70 => /lib/aarch64-linux-gnu/libicudata.so.70 (0x0000ffffae310000) libstdc++.so.6 => /lib/aarch64-linux-gnu/libstdc++.so.6 (0x0000ffffae0e0000) libgcc_s.so.1 => /lib/aarch64-linux-gnu/libgcc_s.so.1 (0x0000ffffae0b0000)
  19. $ php -m [PHP Modules] bcmath, bz2, calendar, Core, ctype,

    curl, date, dba, dom, exif, FFI, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, intl, json, ldap, libxml, mbstring, mysqli, mysqlnd, odbc, openssl, pcntl, pcre, PDO, pdo_dblib, pdo_mysql, PDO_ODBC, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, pspell, random, readline, Reflection, session, shmop, SimpleXML, soap, sockets, sodium, SPL, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tidy, tokenizer, xml, xmlreader, xmlwriter, xsl, Zend OPcache, zip, zlib
  20. $ otool -L /opt/homebrew/bin/php /opt/homebrew/bin/php: /opt/homebrew/opt/tidy-html5/lib/libtidy.58.dylib (compatibility version 58.0.0, current

    version 5.8.0) /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0) /opt/homebrew/opt/aspell/lib/libaspell.15.dylib (compatibility version 19.0.0, current version 19.1.0) /opt/homebrew/opt/aspell/lib/libpspell.15.dylib (compatibility version 19.0.0, current version 19.1.0) /opt/homebrew/opt/libpq/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.16.0) /opt/homebrew/opt/freetds/lib/libsybdb.5.dylib (compatibility version 7.0.0, current version 7.0.0) /opt/homebrew/opt/openldap/lib/libldap.2.dylib (compatibility version 3.0.0, current version 3.200.0) /opt/homebrew/opt/openldap/lib/liblber.2.dylib (compatibility version 3.0.0, current version 3.200.0) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1500.65.0) /usr/lib/libpam.2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) /opt/homebrew/opt/gmp/lib/libgmp.10.dylib (compatibility version 16.0.0, current version 16.0.0) /opt/homebrew/opt/gettext/lib/libintl.8.dylib (compatibility version 13.0.0, current version 13.0.0) /usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.8) /usr/lib/libnetwork.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3) /usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0) /opt/homebrew/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 2.0.0, current version 2.2.0) /opt/homebrew/opt/krb5/lib/libkrb5.3.3.dylib (compatibility version 3.0.0, current version 3.3.0) /opt/homebrew/opt/krb5/lib/libk5crypto.3.1.dylib (compatibility version 3.0.0, current version 3.1.0) /opt/homebrew/opt/krb5/lib/libcom_err.3.0.dylib (compatibility version 3.0.0, current version 3.0.0) /opt/homebrew/opt/openssl@3/lib/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0) /opt/homebrew/opt/openssl@3/lib/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0) /opt/homebrew/opt/pcre2/lib/libpcre2-8.0.dylib (compatibility version 12.0.0, current version 12.2.0) /opt/homebrew/opt/sqlite/lib/libsqlite3.0.dylib (compatibility version 9.0.0, current version 9.6.0) /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11) /opt/homebrew/opt/curl/lib/libcurl.4.dylib (compatibility version 13.0.0, current version 13.0.0) /usr/lib/libffi.dylib (compatibility version 1.0.0, current version 30.0.0) /opt/homebrew/opt/gd/lib/libgd.3.dylib (compatibility version 4.0.0, current version 4.11.0) /opt/homebrew/opt/icu4c/lib/libicuio.74.dylib (compatibility version 74.0.0, current version 74.2.0) /opt/homebrew/opt/icu4c/lib/libicui18n.74.dylib (compatibility version 74.0.0, current version 74.2.0) /opt/homebrew/opt/icu4c/lib/libicuuc.74.dylib (compatibility version 74.0.0, current version 74.2.0) /opt/homebrew/opt/icu4c/lib/libicudata.74.dylib (compatibility version 74.0.0, current version 74.2.0) /opt/homebrew/opt/oniguruma/lib/libonig.5.dylib (compatibility version 10.0.0, current version 10.0.0) /opt/homebrew/opt/unixodbc/lib/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0) /usr/lib/libedit.3.dylib (compatibility version 2.0.0, current version 3.0.0) /opt/homebrew/opt/libsodium/lib/libsodium.26.dylib (compatibility version 28.0.0, current version 28.0.0) /opt/homebrew/opt/argon2/lib/libargon2.1.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0) /usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.15.0) /opt/homebrew/opt/libzip/lib/libzip.5.dylib (compatibility version 5.0.0, current version 5.5.0)
  21. ࣮ʹଟػೳʂʂ { Ұൠత ʁ ͳ1)1͸͜Μͳײ͡ͳΜͰ͢Ͷ { ৭ʑͳػೳΛ࠷ॳ͔Β࢖͏ࣄ͕Ͱ͖ΔΜ͡Όʂ { ʮ͔͠͠·ׂ͋͘Β͍͸ແବͰ͢Ͷʜʯ {

    ʮ40"1͔ͭ͏͔ʁʯʮԶ͸࢖͏ʯʮͦ͏͔ʜେมͩͳʜʯ { ΈΜͳඞཁͳ.PEVMF͸ͪΌΜͱ೺Ѳͯ͠·͔͢ʂʂ
  22. ͰɺҰମɺͲΜͳDPOpHVSFͩͬͨͷ͔ʁ { php -iͰ$POpHVSF$PNNBOEΛௐ΂ΔͱΘ͔Γ·͢ { ͨͩ͠ɺ6CVOUVͱ͔͸ݟΕͳ͍Α͏ʹύον͞Ε͍ͯ·͢ʜ { #SFXͷ1)1͸͜Μͳײ͡Ͱ͢ $ php

    -i |grep configure Configure Command => './configure' '--prefix=/opt/homebrew/Cellar/php/8.3.3_1' '--localstatedir=/opt/homebrew/var' '--sysconfdir=/opt/homebrew/etc/php/8.3' '--with-config-file-path=/opt/homebrew/etc/php/8.3' '--with-config-file-scan-dir=/opt/homebrew/etc/php/8.3/conf.d' '--with-pear=/opt/homebrew/Cellar/php/8.3.3_1/share/php/pear' '--enable-bcmath' '--enable-calendar' '--enable-dba' '--enable-exif' '--enable-ftp' '--enable-fpm' '--enable-gd' '--enable-intl' '--enable-mbregex' '--enable-mbstring' '--enable-mysqlnd' '--enable-pcntl' '--enable-phpdbg' '--enable-phpdbg-readline' '--enable-shmop' '--enable-soap' '--enable-sockets' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-apxs2=/opt/homebrew/opt/httpd/bin/apxs' '--with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr' '--with-curl' '--with-external-gd' '--with-external-pcre' '--with-ffi' '--with-fpm-user=_www' '--with-fpm-group=_www' '--with-gettext=/opt/homebrew/opt/gettext' '--with-gmp=/opt/homebrew/opt/gmp' '--with-iconv=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr' '--with-kerberos' '--with-layout=GNU' '--with-ldap=/opt/homebrew/opt/openldap' '--with-libxml' '--with-libedit' '--with-mhash=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-ndbm=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr' '--with-openssl' '--with-password-argon2=/opt/homebrew/opt/argon2' '--with-pdo-dblib=/opt/homebrew/opt/freetds' '--with-pdo-mysql=mysqlnd' '--with-pdo-odbc=unixODBC,/opt/homebrew/opt/unixodbc' '--with-pdo-pgsql=/opt/homebrew/opt/libpq' '--with-pdo-sqlite' '--with-pgsql=/opt/homebrew/opt/libpq' '--with-pic' '--with-pspell=/opt/homebrew/opt/aspell' '--with-sodium' '--with-sqlite3' '--with-tidy=/opt/homebrew/opt/tidy-html5' '--with-unixODBC' '--with-xsl' '--with-zip' '--with-zlib' '--enable-dtrace' '--with-imap=/opt/homebrew/opt/imap-uw' '--with-imap-ssl=/opt/homebrew/opt/openssl@3' '--with-ldap-sasl' '--with-os-sdkpath=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk' 'PKG_CONFIG_PATH=/opt/homebrew/opt/apr/lib/pkgconfig:/opt/homebrew/opt/openssl@3/lib/pkgconfig:/opt/homebrew/opt/apr-util/lib/pkgconfig:/opt/homebrew/opt/argon2/lib/pkgconfig:/opt/homebrew/opt/brotli/lib/pkgconfig:/opt/homebrew/opt/libidn2/lib/pkgconfig:/opt/homebrew/opt/libnghttp2/lib/pkgconfig:/opt/homebrew/opt/libssh2/lib/pkgconfig:/opt/homebrew/opt/openldap/lib/pkgconfig:/opt/homebrew/opt/rtmpdump/lib/pkgconfig:/opt/homebrew/opt/lz4/lib/pkgconfig:/opt/homebrew/opt/xz/lib/pkgconfig:/opt/homebrew/opt/zstd/lib/pkgconfig:/opt/homebrew/opt/curl/lib/pkgconfig:/opt/homebrew/opt/unixodbc/lib/pkgconfig:/opt/homebrew/opt/libpng/lib/pkgconfig:/opt/homebrew/opt/freetype/lib/pkgconfig:/opt/homebrew/opt/fontconfig/lib/pkgconfig:/opt/homebrew/opt/jpeg-turbo/lib/pkgconfig:/opt/homebrew/opt/highway/lib/pkgconfig:/opt/homebrew/opt/imath/lib/pkgconfig:/opt/homebrew/opt/libtiff/lib/pkgconfig:/opt/homebrew/opt/little-cms2/lib/pkgconfig:/opt/homebrew/opt/openexr/lib/pkgconfig:/opt/homebrew/opt/webp/lib/pkgconfig:/opt/homebrew/opt/jpeg-xl/lib/pkgconfig:/opt/homebrew/opt/libvmaf/lib/pkgconfig:/opt/homebrew/opt/aom/lib/pkgconfig:/opt/homebrew/opt/libavif/lib/pkgconfig:/opt/homebrew/opt/gd/lib/pkgconfig:/opt/homebrew/opt/gmp/lib/pkgconfig:/opt/homebrew/opt/icu4c/lib/pkgconfig:/opt/homebrew/opt/krb5/lib/pkgconfig:/opt/homebrew/opt/libpq/lib/pkgconfig:/opt/homebrew/opt/libsodium/lib/pkgconfig:/opt/homebrew/opt/libzip/lib/pkgconfig:/opt/homebrew/opt/oniguruma/lib/pkgconfig:/opt/homebrew/opt/pcre2/lib/pkgconfig:/opt/homebrew/opt/readline/lib/pkgconfig:/opt/homebrew/opt/sqlite/lib/pkgconfig:/opt/homebrew/opt/tidy-html5/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/13' 'KERBEROS_CFLAGS= ' 'SASL_CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sasl' 'SASL_LIBS=-lsasl2' { ˢʜΈ͑·͢ʁҰߦʹͳͬͯΔͱݟ͑ͳ͍Ϩϕϧ
  23. ͪΐͬͱվߦೖΕͯΈ͕ͨɺੋඇࣗ͝਎ͰΈ͍ͯͩ͘͞ɻ ./configure --prefix=/opt/homebrew/Cellar/php/8.3.3_1 --localstatedir=/opt/homebrew/var --sysconfdir=/opt/homebrew/etc/php/8.3 --with-config-file-path=/opt/homebrew/etc/php/8.3 --with-config-file-scan-dir=/opt/homebrew/etc/php/8.3/conf.d --with-pear=/opt/homebrew/Cellar/php/8.3.3_1/share/php/pear --enable-bcmath --enable-calendar

    --enable-dba --enable-exif --enable-ftp --enable-fpm --enable-gd --enable-intl --enable-mbregex --enable-mbstring --enable-mysqlnd --enable-pcntl --enable-phpdbg --enable-phpdbg-readline --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-apxs2=/opt/homebrew/opt/httpd/bin/apxs --with-bz2=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr --with-curl --with-external-gd --with-external-pcre --with-ffi --with-fpm-user=_www --with-fpm-group=_www --with-gettext=/opt/homebrew/opt/gettext --with-gmp=/opt/homebrew/opt/gmp --with-iconv=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr --with-kerberos --with-layout=GNU --with-ldap=/opt/homebrew/opt/openldap --with-libxml --with-libedit --with-mhash=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr --with-mysql-sock=/tmp/mysql.sock --with-mysqli=mysqlnd --with-ndbm=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr --with-openssl --with-password-argon2=/opt/homebrew/opt/argon2 --with-pdo-dblib=/opt/homebrew/opt/freetds --with-pdo-mysql=mysqlnd --with-pdo-odbc=unixODBC,/opt/homebrew/opt/unixodbc --with-pdo-pgsql=/opt/homebrew/opt/libpq --with-pdo-sqlite --with-pgsql=/opt/homebrew/opt/libpq --with-pic --with-pspell=/opt/homebrew/opt/aspell --with-sodium --with-sqlite3 --with-tidy=/opt/homebrew/opt/tidy-html5 --with-unixODBC --with-xsl --with-zip --with-zlib --enable-dtrace --with-imap=/opt/homebrew/opt/imap-uw --with-imap-ssl=/opt/homebrew/opt/openssl@3 --with-ldap-sasl --with-os-sdkpath=/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk PKG_CONFIG_PATH=/opt/homebrew/opt/apr/lib/pkgconfig: :/opt/homebrew/opt/openssl@3/lib/pkgconfig :/opt/homebrew/opt/apr-util/lib/pkgconfig :/opt/homebrew/opt/argon2/lib/pkgconfig :/opt/homebrew/opt/brotli/lib/pkgconfig :/opt/homebrew/opt/libidn2/lib/pkgconfig :/opt/homebrew/opt/libnghttp2/lib/pkgconfig :/opt/homebrew/opt/libssh2/lib/pkgconfig :/opt/homebrew/opt/openldap/lib/pkgconfig :/opt/homebrew/opt/rtmpdump/lib/pkgconfig :/opt/homebrew/opt/lz4/lib/pkgconfig :/opt/homebrew/opt/xz/lib/pkgconfig :/opt/homebrew/opt/zstd/lib/pkgconfig :/opt/homebrew/opt/curl/lib/pkgconfig :/opt/homebrew/opt/unixodbc/lib/pkgconfig :/opt/homebrew/opt/libpng/lib/pkgconfig :/opt/homebrew/opt/freetype/lib/pkgconfig :/opt/homebrew/opt/fontconfig/lib/pkgconfig :/opt/homebrew/opt/jpeg-turbo/lib/pkgconfig :/opt/homebrew/opt/highway/lib/pkgconfig :/opt/homebrew/opt/imath/lib/pkgconfig :/opt/homebrew/opt/libtiff/lib/pkgconfig :/opt/homebrew/opt/little-cms2/lib/pkgconfig :/opt/homebrew/opt/openexr/lib/pkgconfig :/opt/homebrew/opt/webp/lib/pkgconfig :/opt/homebrew/opt/jpeg-xl/lib/pkgconfig :/opt/homebrew/opt/libvmaf/lib/pkgconfig :/opt/homebrew/opt/aom/lib/pkgconfig :/opt/homebrew/opt/libavif/lib/pkgconfig :/opt/homebrew/opt/gd/lib/pkgconfig :/opt/homebrew/opt/gmp/lib/pkgconfig :/opt/homebrew/opt/icu4c/lib/pkgconfig :/opt/homebrew/opt/krb5/lib/pkgconfig :/opt/homebrew/opt/libpq/lib/pkgconfig :/opt/homebrew/opt/libsodium/lib/pkgconfig :/opt/homebrew/opt/libzip/lib/pkgconfig :/opt/homebrew/opt/oniguruma/lib/pkgconfig :/opt/homebrew/opt/pcre2/lib/pkgconfig :/opt/homebrew/opt/readline/lib/pkgconfig :/opt/homebrew/opt/sqlite/lib/pkgconfig :/opt/homebrew/opt/tidy-html5/lib/pkgconfig PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/13 KERBEROS_CFLAGS= SASL_CFLAGS=-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/sasl SASL_LIBS=-lsasl2
  24. Ͱ͸ɺϛχϚϧɺʮૉʯΛͭͬͯ͘ΈΑ͏ { configure --disable-all͢Δͱɺ શ෦ͷ ֎͢͜ͱ͕Ͱ͖Δ ֦ுϞδϡʔϧΛམͱͤ·͢ { ͜ΕͰɺϛχϚϧͳ 1)1͕Ͱ͖·͢

    $ php -m [PHP Modules] Core, date, hash, json, pcre, random, Reflection, SPL, standard [Zend Modules] { YNMͱ͔TRMJUFͱ͔͕ͳ͍Ͱ͢ͶɺͳΜͱ4FTTJPO΋ͳ͍Ͱ͢
  25. ͜ͷόΠφϦΛMEEͰΈͯΈΔ $ ldd /tmp/myphp/bin/php linux-vdso.so.1 (0x0000ffff943de000) libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff93cf0000)

    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff93b40000) /lib/ld-linux-aarch64.so.1 (0x0000ffff943a5000) { WETP͸-JOVYͷ4ZTUFNDBMMͷͨΊ { MJCD ͱMJCN ͸$ͷඪ४ϥΠϒϥϦ { MEMJOVY ͸%40ͷͨΊ ޙड़ { ࠷௿ݶͷ1)1όΠφϦ͸͜Μͳײ͡
  26. ༨ஊHMJCDͰͳ͘ɺNVTMͷྫ /tmp/php-src $ ldd /usr/local/bin/php /lib/ld-musl-aarch64.so.1 (0xffff887fb000) libc.musl-aarch64.so.1 => /lib/ld-musl-aarch64.so.1

    (0xffff887fb000) { NVTM͸HMJCDͬΆ͍φχΧͰ͢ɺओʹBMQJOFͷຽ͕࢖͍·͢ { MJCD͸ඪ४ϥΠϒϥϦͰɺHMJCDͳͲ͕جຊͰ͢ { HMJCD͸(/6ͷMJCDͰ͢ɺσϑΝΫτελϯμʔυͰ͢ { NVTM͸ίϯύΫτ౳ͷಛ௃͕͋Γ·͢ ͕ɺHMJCDͱͷ׬શͳޓ׵ੑ͸͋Γ·ͤΜ
  27. ༨ஊNVTM BMQJOFͰϏϧυ͢Δखॱ $ docker run --rm -it alpine:latest /bin/sh #

    ҎԼ͸alpineͷத apk add alpine-sdk wget git autoconf bison re2c git clone --branch php-8.3.3 --depth 1 https://github.com/php/php-src.git cd php-src/ ./buildconf --force ./configure --disable-all make -j10 make install ldd /usr/local/bin/php
  28. ʮQIQFOWͱ͔ͰQIQΛ࡞ΔͱյΕΔʯͷ࿩ { QIQFOW QIQCVJME Ͱ࡞Δͱɺ͍ͭͷ·ʹ͔յΕΔ $ php -v dyld[8400]: Library

    not loaded: /opt/homebrew/opt/icu4c/lib/libicuio.71.dylib Referenced from: <814BECD3-10C1-3A8C-985D-7435694597D3> /opt/homebrew/Cellar/[email protected]/7.4.32/bin/php Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuio.71.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuio.71.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuio.71.dylib' (no such file), '/usr/local/lib/libicuio.71.dylib' (no such file), '/usr/lib/libicuio.71.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicuio.71.dylib'(no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/74.2/lib/libicuio.71.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/74.2/lib/libicuio.71.dylib' (no such file), '/usr/local/lib/libicuio.71.dylib' (no such file), '/usr/lib/libicuio.71.dylib' (no such file, not in dyld cache) Abort trap: 6 { ͜Ε͸ɺ #SFX౳ͰೖΕͨ ϥΠϒϥϦ͕ফ͑ͨͷͰى͜ΔΤϥʔ { ղΓͮΒ͍ΜͰɺ-JOVYͰͨΊͯ͠Έ·͠ΐ͏
  29. Ϗϧυ΍Γ௚ͯ͠͠ΈΔ apt update // Լ͸͋͑ͯlibxml2-dev libsqlite3-dev Λ͸͍ͣͯ͠Δ apt install -y

    git pkg-config build-essential autoconf bison re2c wget git clone --depth 1 https://github.com/php/php-src.git cd php-src `./buildconf` ./configure --prefix=/tmp/yaphp # ͜͜Ͱґଘ͕ͳ͍ͷͰࣦഊ͢Δ͸ͣ
  30. # sqlite apt install wget wget https://www.sqlite.org/2024/sqlite-autoconf-3450100.tar.gz tar xvzf sqlite-autoconf-3450100.tar.gz

    cd sqlite-autoconf-3450100 ./configure --prefix=/tmp/yaphp make -j10 make install # libxml2 wget https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz tar xvzf v2.12.5.tar.gz cd libxml2-2.12.5/ apt install -y libtool python3-dev ./autogen.sh ./configure --prefix=/tmp/yaphp/ make -j10 make install
  31. Α͠ɺґଘΛࢦఆͯ͠Ϗϧυ͠Α͏ { ϙΠϯτ͸PKG_CONFIG_PATHΛࢦఆ͢Δ͜ͱͰ͢ ͜ΕͰɺґଘϥΠϒϥϦ͕ࢦఆͰ͖·͢ $ ./configure \ PKG_CONFIG_PATH="/tmp/yaphp/lib/pkgconfig:$PKG_CONFIG_PATH"\ --prefix=/tmp/yaphp/ --with-libxml

    --with-sqlite3 $ make -j10; make install { ݹདྷ͸-%'-"(ͱ͔Λ͍ͬͯ͡·͕ͨ͠ࡢࠓ͸͕ͬͪ͜ओྲྀ { ͜ͷ͋ͨΓ͸CSFXͱ͔ͷ$POpHVSFઃఆΛΈΔͱࢀߟʹͳΓ·͢Ͷ
  32. ֬ೝ { ग़དྷͨόΠφϦΛphp -iͰ֬ೝ $ /tmp/yaphp/bin/php -i |grep -i -e

    libxml -e sqlite libxml libXML Compiled Version => 2.12.5 <=͜Ε pdo_sqlite SQLite Library => 3.45.1 <=͜Ε { ࣗ෼ͰϏϧυͨ͠ϥΠϒϥϦόʔδϣϯͩʂ
  33. MEEͰࢀরઌΛ֬ೝ root@e7cd4cf2a459:/php-src# ldd /tmp/yaphp/bin/php linux-vdso.so.1 (0x0000ffff93c6f000) libsqlite3.so.0 => /tmp/yaphp/lib/libsqlite3.so.0 (0x0000ffff928a0000)

    libxml2.so.2 => /tmp/yaphp/lib/libxml2.so.2 (0x0000ffff92720000) libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff92680000) libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff924d0000) /lib/ld-linux-aarch64.so.1 (0x0000ffff93c36000) libz.so.1 => /lib/aarch64-linux-gnu/libz.so.1 (0x0000ffff924a0000) { /usr/libͰͳ͘/tmp/yaphp/libΛࢀরͯ͠·͢
  34. ͯ͞ɺ͓΋ΉΖʹTPΛ࡟আͯ͠ΈΑ͏ $ /tmp/yaphp/bin/php -v PHP 8.4.0-dev (cli) (built: Mar 2

    2024 08:37:20) (NTS) $ ldd /tmp/yaphp/bin/php | grep libxml2.so (ུ) libxml2.so.2 => /tmp/yaphp/lib/libxml2.so.2 (0x0000ffff9a570000) $ rm /tmp/yaphp/lib/libxml2.so* $ /tmp/yaphp/bin/php -v /tmp/yaphp/bin/php: symbol lookup error: /tmp/yaphp/bin/php: undefined symbol: xmlFreeEntity { ແࣄ͜ΘΕ·ͨ͠Ͷ
  35. ʮͱ͜ΖͰMEE PUPPM ͬͯͳΜͳΜʁʯ { lddɺotool͸ϦϯΫ͞ΕͯΔಈతϥΠϒϥϦ ˞ ֬ೝ͢ΔίϚϯυ { ˞͜͜Ͱ͸ಈతϦϯΫΛ͢͞ɺಈతϩʔυ͸͜͜Ͱ͸ׂѪ {

    -JOVY͸*.soɺ8JO͸*.dllɺ.BD͸*.dylib { ྫ͑͹ { MJCYNM͸ଟ͘ͷόΠφϦͰ࢖ΘΕΔͷͰɺڞ༗͢ΔͱΤίʂ { ੬ऑੑରԠ΋ɺTPϑΝΠϧ͚ͩΞοϓσʔτ͢Ε͹͍͍͔Βศརʂ
  36. # ৭ʑ(SSLͱ͔)͕໘౗ͳͷͰ΍Γ௚͠·͢ apt update apt install -y git pkg-config build-essential

    autoconf \ bison re2c libxml2-dev libsqlite3-dev zlib1g-dev \ libssl-dev libreadline-dev # ҎԼ͸PHPͷόʔδϣϯΛࢦఆͯ͠Ϋϩʔϯ͍ͯ͠Δ git clone --branch php-8.3.3 --depth 1 https://github.com/php/php-src.git cd php-src ./buildconf --force # peclΛ࢖͏ʹ͸configureͰ `--with-pear`Λ௥Ճ͢Δඞཁ͕͋Δ ./configure --with-openssl -with-readline --with-pear make -j10 make install
  37. %40͸ϏϧυͤͣɺΦϯΦϑͰ͖Δ $ php -dzend_extension=xdebug.so -r "xdebug_info();"| head __ __ _

    _ \ \ / / | | | | \ V / __| | ___| |__ _ _ __ _ > < / _` |/ _ \ '_ \| | | |/ _` | / . \ (_| | __/ |_) | |_| | (_| | /_/ \_\__,_|\___|_.__/ \__,_|\__, | __/ | |___/ $ php -r "xdebug_info();"| head Fatal error: Uncaught Error: Call to undefined function xdebug_info() in Command line code:1 Stack trace: #0 {main} thrown in Command line code on line 1
  38. ༨ஊϚχϡΞϧͰ֦ுϞδϡʔϧͷೖΕํ { QFDM͕ͳͯ͘΋ೖΕΒΕΔ wget https://github.com/xdebug/xdebug/archive/refs/tags/3.3.1.tar.gz cd xdebug-3.3.1 phpize ./configure make

    -j10 make install { ಉ༷ʹxdebug.so͕Ͱ͖ΔͷͰɺphp.ini౳ʹ௥Ճ͢Δ { ࣮ମ͕Ͳ͜ʹ͋Δ͔͸php -iͷextension_dirͰΘ͔Δ
  39. ඪ४Ϟδϡʔϧ΋%40ʹͰ͖Δ { ྫͱͯ͠ɺTRMJUFΛ%40ʹͯ͠Έ·͢ $ ./configure --with-sqlite3=shared (লུ) $ ls -al

    /path/to/extensions/ |grep sqlite3.so -rwxr-xr-x 1 root root 263312 Mar 5 02:23 sqlite3.so $ ./configure --with-sqlite3 (লུ) $ ls -al /path/to/extensions/ |grep sqlite3.so (ແ͍) { جຊ--with-*=sharedͰTIBSFEʹͳΔ͕ɺͰ͖ͳ͍΋ͷ΋͋Γ·͢
  40. ޙ೔ʹ1)1ͷඪ४ϞδϡʔϧΛ%40ͱͯ͠௥Ճ͢Δ { QHTRMͱ͔͸ʮ࠶Ϗϧυʯ͍ͨ͜͠ͱ͕͋Δͱࢥ͏ { ໺ྑ3FQP͸MJCQRͷόʔδϣϯ͕αʔόʔͱἧͬͯͳ͍ࣄ͕͋Δ apt install -y libpq-dev #

    ͳΜΒ͔ɺpgͷϥΠϒϥϦΛ͍ΕΔ cd php-src/ext/pgsql phpize make -j10; make install # extension_dir ʹ pgsql.so͕Ͱ͖ΔͷͰɺ͋ͱ͸load͢Δ # PDO(pdo_pgsql)΋ಉ༷ { BQUͰ͍Ε͍ͯͯ΋ɺόʔδϣϯΛͦΖ͑Ε͹ϏϧυͰ͖·͢
  41. ٯʹɺඇඪ४ͷ"1$VΛ%40Ͱͳ͘ɺ4UBUJDʹೖΕͯΈΔ # ҎԼͷdirͰ͋Δ͜ͱ͕ॏཁ cd php-src/ext/ wget https://pecl.php.net/get/apcu-5.1.23.tgz tar xzf apcu-5.1.23.tgz

    mv apcu-5.1.23 apcu # php-src/ext/apcu ͱͳΔ૝ఆ cd .. ./buildconf --force ./configure {লུ} --enable-apcu { configure -hʹ--enable-apcu͕ੜ͑Δ
  42. DIFDL $ php --ini Configuration File (php.ini) Path: /usr/local/lib Loaded

    Configuration File: (none) <== ͳΜʹ΋ Scan for additional .ini files in: (none) <== ઃఆ Additional .ini files parsed: (none) <== ͯ͠·ͤΜ $ php -m [PHP Modules] apcu
  43. ༨ஊ1)1ͱଞͷݴޠʹ͓͚Δಛ௃తͳ$֦ுͷࠩҟ { ଞͷݴޠͩͱɺDPNQPTFSతͳ෺ OQN౳ Ͱ$֦ு͕͸͍Δ { 1)1͸ͦ͏͍ͯ͠ͳ͍ $ݴޠΛར༻֦ͨ͠ு͸ϞδϡʔϧʹͳΔ { dl()Λੵۃతʹ࢖͏ίʔυ͸͋·Γͳ͍

    { $PNQPTFSͷ"VUPMPBEͱ૬ੑ͕ѱ͍ͷ΋͋Δ͕ ଟ෼1SFGPSLͱ૬ੑ͕ѱ͍͔Βͩͱ͓΋͍·͢ { ͳͷͰʜ { 1)1ͷϥΠϒϥϦ͸Ϗϧυϔϧ͕গͳ͍ { ٯʹɺϥϯλΠϜΛ࡞Δͷʹଟগ஌͕ࣝඞཁ
  44. NPE@QIQͷϏϧυʹ͍ͭͯ { DMJͷ࿩ DHJ΍GQN΋͓ͳ͡Ͱ͕͢ ΋͋ͬͨͷͰҰԠ"QBDIF΋ { NPE@QIQ͸"QBDIFͷͨΊͷ1)1ͷ%40Ͱ͋Δ { QIQΛ--with-apxs2෇͖ͰϏϧυ͢ΔͱɺNPE@QIQ͕Ͱ͖Δ {

    BQYT͸BQUͩͱapache2-dev͕ඞཁ $ apt install -y apache2-dev apache2 $ which apxs2 /usr/bin/apxs2 # ͋Δ͜ͱΛ֬ೝ͢Δ
  45. $ ./configure \ --with-pear --with-openssl \ --with-readline --enable-apcu --with-apxs2 $

    make -j10 $ make install Installing PHP SAPI module: apache2handler (ϑΝΠϧ͕apacheͷmodule dirʹೖΔ) { ࣮ମ͸libphp.soͰɺ͜ΕΛ"QBDIFͷLoadModuleͰಡΈࠐΉ
  46. # Apacheͷௐ੔͕ͪΐͬͱඞཁ(Preforkʹ͍ͨ͠ͷͰ) $ a2dismod mpm_event $ a2enmod mpm_prefork $ a2enmod

    php # Load ModuleΛ༗ޮԽ # SetHandlerΛઃఆ $ echo \ "<FilesMatch \.php$>SetHandler application/x-httpd-php</FilesMatch>"\ > /etc/apache2/conf-available/php.conf $ a2enconf php # ςετ༻ͷϑΝΠϧΛద౰ʹ… $ echo "<?php phpinfo();" >> /var/www/html/test.php
  47. # module͕͸͍͍ͬͯΔ͔֬ೝ $ apache2 -M | grep php php_module (shared)

    <== ͦ͏ɺ͜Ε΋DSOͳΜͰ͢ΑͶʙʙ # dockerͳͷͰɺsystemd͕ͳ͍ͨΊɺϚχϡΞϧͰapacheΛىಈ͠·͢… $ apache2ctl start # ͪΌΜͱىಈ͍ͯ͠Δ͔֬ೝ $ ps -Al |grep apache2 5 S 0 17114 1 0 80 0 - 25734 do_sel ? 00:00:01 apache2 # ͪΌΜͱಈ͍͍ͯΔ͔֬ೝ $ wget -q -O - http://localhost/test.php \ | grep -e "<title>" -e APCu <title>PHP 8.3.3 - phpinfo()</title>(ུ) <tr><td class="e">APCu Support </td>(ུ)
  48. ͭ·Γɺ਺चͭͳ͗Ͱ͢Ͷ [Apache HTTP Server] | | (ϩʔυɺઃఆ࣍ୈ) v [libphp.so (PHPͷDSO)]

    | | (staticͳΒίϯύΠϧ࣌ʹࢦఆɺඞਢ) | (DSOͳΒphp.iniઃఆ࣍ୈ) v [LibXML2 (DSO)] { ݹདྷ͸͜ΕΒΛશ෦ҰݸʹͰ͖͕ͨࡢࠓͰ͖·ͤΜͶɺऐ͍͠
  49. 1)1ͷߏ੒ɺϏϧυಓ { 1)1ͷ؀ڥߏங͸Ϟδϡʔϧ͕ॏཁ { ઃఆܥ͸QIQJOJͰมߋग़དྷΔࣄ͕ଟ͍ { ʮQIQJOJ͸ʁʯʮੲτʔΫͨ͠ͷͰQIQJOJͷ࿩Ͱάάͬͯʯ { IUUQTTQFBLFSEFDLDPNV[VMMBQIQEPUJOJGBMTFIVB {

    %40ɺґଘϥΠϒϥϦ΋ཧղͯ͠΋Β͑Δͱ͏Ε͍͠ { ࣗલͰϏϧυͰ͖Ε͹ɺυϯυϯ࠷৽൛Λ࢖ͬͨΓ΋Ͱָ͖͍ͯ͠ { ʮ͜ΜͳτʔΫ͸ୀ۶ʁͰ͸.BLFpMFͷਂ෵Λͷ͖ͧࠐΉΜͩʂʯ { ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ࣭໰͍ͯͩ͘͠͞ʂ
  50. ੩తͱಈత { 1)1ͷϞδϡʔϧ͸4UBUJDͱ%40Λ େ఍ બ΂Δ { ࣮ߦ࣌ʹ͸ ΄΅ ͲͪΒ΋ಉ͡ͱࢥͬͯྑ͍ {

    ຊདྷɺߏ੒มߋͷॊೈ͕͞ඞཁ͔ߟ͑ͯબͿͱΑͦ͞͏ { େ͸খΛ݉ͶΔɺશ෦ೖΓͳΒࠔΒͳ͍ͱ΋ݴ͑Δ { ηΩϡϦςΟతʹ͸4UBUJDͳΒαΠυϩʔυͰ͖ͳ͍ͱ͔͋Δ
  51. 6CVOUV POESFK ͷ༷ࢠΛΈͯΈΔ # UbuntuͷDockerͰ࠷଎ͰೖΕͯΈΔ apt update apt install -y

    software-properties-common add-apt-repository ppa:ondrej/php add-apt-repository ppa:ondrej/apache2 apt update apt install -y apache2 php8.3 a2enmod php8.3 apachectl start
  52. # DSOͷϑΝΠϧ͕͋Δ $ ls /usr/lib/php/20230831 calendar.so ctype.so exif.so ffi.so fileinfo.so

    ftp.so gettext.so iconv.so opcache.so pdo.so phar.so posix.so readline.so shmop.so sockets.so sysvmsg.so sysvsem.so sysvshm.so tokenizer.so
  53. # config͸ availableʹ࣮ମ͕͋Γɺ # enmodίϚϯυͰSymlink͞Εͯ༗ޮԽ͞ΕΔ /etc/php/8.3# find . ./mods-available/gettext.ini ./mods-available/ctype.ini

    ./mods-available/iconv.ini (ུ) ./cli/conf.d/20-iconv.ini <== ্͔ΒͷSymlink ./cli/conf.d/20-sockets.ini ./cli/php.ini (ུ) ./apache2/conf.d/20-iconv.ini ./apache2/conf.d/20-sockets.ini (ུ)
  54. 6CVOUV POESFK ͷࢥ૝ { ༗໊ͳϞδϡʔϧʹ͍ͭͯ͸ɺQFDMෆཁͰ apt install php8.3-redisͱ͔Ͱ௥ՃͰ͖Δ { 6CVOUV͸*enmod*dismodͰΦϯΦϑ͢Δࢥ૝͕͋Δ

    { QIQFONPEQIQEJTNPEͱ͍͏ίϚϯυͰ੍ޚͰ͖Δ { DPOpH͕݁ߏෳࡶʹͳ͍ͬͯΔ͕ɺ ֎ͤΔͱ͍͏ҙຯͰ͸ʮϛχϚϧʯͳͷ͔΋͠Εͳ͍
  55. ެࣜ%PDLFSͷQIQͷ༷ࢠΛݟͯΈΔ { docker run -it --rm php:cli /bin/bash { ͨͬͨݸ͘Β͍ͷϞδϡʔϧ͕ೖ͍ͬͯΔ

    { DPNQPTFS΋ͳ͍ͷ͸༗໊ ඞਢͩΖʜԿͰೖͬͯͳ͍Μͩʜʁ { ͦͯ͠ɺ%40ͷσΟϨΫτϦ͸PQDBDIFͱTPEJVN͚ͩ { ΄ͱΜͲTUBUJD #SFXͱ͍ۙ { ͨͩ͠ɺগ͠πʔϧ͕ೖ͍ͬͯΔ
  56. ͦͷ୅ΘΓʹπʔϧ͕͍ͭͯ͘Δ docker-php-ext-configure # ϏϧυΦϓγϣϯઃఆ docker-php-ext-install # ϞδϡʔϧΠϯετʔϧ docker-php-ext-enable # config༗ޮԽ

    { ͜ΕΒͰQIQͷඪ४Ϟδϡʔϧ͕ઃఆͰ͖Δ { HEͱ͔ɺQEP@QHTRMͱ͔ { ඪ४Ͱ͸ͳ͍QFDMͷSFEJT΍YEFCVH౳͸QFDMͰೖΕΔ { EPDLFSQIQFYUFOBCMF͚ͩ͸࢖͑Δ
  57. ʮࣗલͰ࡞Δͷͬͯා͍ؾ͕͢Δʯ { ͦΜͳ͜ͱͳ͍ ݸਓతओ؍ ɺಉ͡ߏ੒ͳΒ΄΅ࠩ͸ͳ͍ { SFNJ౳͸ɺόʔδϣϯϩοΫͰ͖ΔΘ͚Ͱ͸ͳ͍ͷͰ஫ҙ͕ඞཁ { ࡞Γ௚͢ͱɺաڈͷQLH͕ແ͘ɺڧ੍όʔδϣϯมߋ΋ {

    QLHΛશ෦%-ͯ͠ͱ͓ͬͯ͘ɺͱ͍͏ςΫ΋͋Δ͕େม { ࠷ۙ͸࠷৽൛ʹ௥ै͢Δݱ৔͕૿͍͑ͯΔͷͰɺͦΕͰ΋ྑ͍ͷ͔΋͠ Εͳ͍͕ { ʮݹདྷ͸ࣗࣾͰSQNEFCΛ࡞͍ͬͯͨΜ͡Όʯ
  58. ͱɺ͍͏͜ͱͰEFCύοέʔδΛ࡞ͬͯΈΔ { લఏɺ/tmp/debphpʹEFCԽ͍ͨ͠QIQΠϯετʔϧ͕͋Δͱ͢Δ { ͜ΕΛEFCύοέʔδʹͯ͠ΈΑ͏ # πʔϧΠϯετʔϧ apt -y install

    dh-make devscripts build-essential # ࡞ۀσΟϨΫτϦͷrootͱɺDEBIANΛͭ͘Δ mkdir /tmp/root mkdir /tmp/root/DEBIAN # rootʹ·Δ͝ͱίϐʔ͢Δ (/tmp/root/debphp ͕Ͱ͖Δ) cp -a /tmp/debphp /tmp/root
  59. ઃఆʂ { /tmp/root/DEBIAN/controlઃఆϑΝΠϧΛ࡞Δ { %FQFOETʹґଘϥΠϒϥϦΛࢦఆ͢Δ MJCYNM TRMJUF { *OTUBMMFE4J[F͕ӕͳͷ͸͝Ѫܟ Package:

    debphp Version: 1.0 Section: custom Priority: optional Architecture: all Essential: no Installed-Size: 1024 Maintainer: uzulla <[email protected]> Description: An example PHP package Depends: libxml2 (>= 2.9.1), sqlite3 (>= 3.7.15)
  60. ࡞੒ͨ͠EFCͷத਎ΛΈͯΈΔ $ dpkg-deb --contents /debphp_1.0_all.deb drwxr-xr-x root/root 0 2024-03-05 17:00

    ./ drwxr-xr-x root/root 0 2024-03-05 16:59 ./tmp/ drwxr-xr-x root/root 0 2024-03-05 17:00 ./tmp/debphp/ drwxr-xr-x root/root 0 2024-03-05 16:50 ./tmp/debphp/bin/ -rwxr-xr-x root/root 65991 2024-03-05 16:50 ./tmp/debphp/bin/phar.phar ...
  61. ࢼݧػʹEFCΛίϐʔ { ผͷۭͬΆͷ6CVOUVΛ্ཱͪ͛ͯɺͦΕʹ*OTUBMMͯ͠ΈΔ # ίϯςφΛىಈͨ͠··ɺdebϑΝΠϧΛϗετϚγϯʹͱΓͩ͢ # (ίϯςφID͸ docker psͰ͠Β΂͍ͯͩ͘͞) docker

    cp {Ϗϧυͨ͠container_id}:/tmp/debphp_1.0_all.deb . # ผ΢Πϯυ΢ͰผͷUbuntuΛ্ཱͪ͛Δ docker run --rm -it ubuntu:latest /bin/bash # ৽ίϯςφʹίϐʔ͢Δ docker cp ./debphp_1.0_all.deb {৽ίϯςφ}:/
  62. ϨοπΠϯετʔϧʂ $ apt update # ·ͣ͸Ξοϓσʔτ,ඞਢ $ apt install /debphp_1.0_all.deb

    # ↓ εΰΠʂlibxml2ͱ͔sqlite3ͱ͔ґଘੑ͕ղܾ͞Ε͍ͯΔͧʂʂ The following additional packages will be installed: libicu70 libreadline8 libsqlite3-0 libxml2 readline-common sqlite3 The following NEW packages will be installed: debphp libicu70 libreadline8 libsqlite3-0 libxml2 readline-common sqlite3 0 upgraded, 7 newly installed, 0 to remove and 24 not upgraded. Setting up debphp (1.0) ... Processing triggers for libc-bin (2.35-0ubuntu3.4) ... # ແࣄಈ࡞ʂ $ /tmp/debphp/bin/php -v PHP 8.3.3 (cli) (built: Mar 5 2024 16:21:05) (NTS)