Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build PHP7 with lmdb support (or another needed) on MacOS in Homebrew

This method is suitable for compiling PHP from the source code not only for LMDB, but also through it you can perform any kind of configuration before installation.

Install lmdb

Unfortunately, it is currently not possible to change the database size and it is fixed at a size of 1MB (this restriction is defined in the library itself). To get around this, you need to patch the library itself before installation. Look here as: https://gist.github.com/saippuakauppias/95b6f7b139b3d117b7dac4aeead9f5b4

Proper way (not worked)

Build php7 from sources

--interactive: Download and patch formula, then open a shell. This allows the user to run ./configure --help and otherwise determine how to turn the software package into a Homebrew package.

brew install --build-from-source --interactive php

==> Installing php ==> Downloading https://www.php.net/distributions/php-7.3.11.tar.xz ==> Patching patching file acinclude.m4 Hunk #5 succeeded at 2504 (offset 85 lines). ==> Entering interactive mode Type exit to return and finalize the installation Install to this prefix: /usr/local/Cellar/php/7.3.11 ➜ php-7.3.11 #

./configure --with-lmdb=/usr/local/opt/lmdb
# ??? 
# need more args in `configure` or `make install`?
make
make test
exit

Hacker-style way

Update brew & patch formula

brew update
brew edit php

Need find --enable-dba and add below:

--with-lmdb=#{Formula["lmdb"].opt_prefix}

Build from sources

brew install --build-from-source php

Verify

In another terminal tab

php -v
php -i | grep lmdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.