Search code examples
phpmacosasdf-vm

How to install PHP 7.2.18 via asdf-php Plugin on MacOS


I'm trying to install PHP 7.2 via the asdf-php plugin.

I see a lot of error messages for missing libs (openssl, readline, zlib, ...).


Solution

  • After lots of researches, trail and error and digging through GitHub issues, I found that this plugin is abandoned due to huge differences in the PHP build process. However I found a solution by doing the following:

    xcode-select --install
    
    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
    
    brew tap magrathealabs/homebrew-mlabs
    brew install pkg-config freetype bison bison27 gettext icu4c icu4c@58.1 jpeg libiconv libpng openssl readline zlib libedit
    
    ln -s /usr/local/Cellar/openssl/1.0.2r/include/openssl /usr/local/include/openssl
    
    export PHP_CONFIGURE_OPTIONS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-iconv=$(brew --prefix libiconv) --with-readline=$(brew --prefix readline) --with-libedit=$(brew --prefix libedit) --with-tidy=$(brew --prefix tidy-html5)"
    
    export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/icu4c@58.1/lib/pkgconfig"
    
    export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/openssl/include -I/usr/local/opt/libedit/include -I/usr/local/opt/readline/include -I/usr/local/opt/icu4c@58.1/include"
    
    export LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl/lib -L/usr/local/opt/bison/lib -L/usr/local/opt/libedit/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/icu4c@58.1/lib"
    
    export PATH="$(brew --prefix bison)/bin:$(brew --prefix icu4c@58.1)/bin:$(brew --prefix icu4c)/sbin:$PATH"
    
    
    
    asdf install 7.2.18