'configure: error: Please reinstall the BZip2 distribution

I am trying to compile php from source on mac with the bzip2 extension and I keep getting an error saying

checking for BZip2 in default path... not found

I've tried setting the LDFLAGS and CPPFLAGS but that doesn't seem to work.

The dylib is in /usr/local/opt/bzip2/lib and the header files are in usr/local/opt/bzip2/include.



Solution 1:[1]

I had the exact same issue. I resolved it by installing bzip2 by using brew.

brew install bzip2

Solution 2:[2]

This also works:

sudo apt-get install libbz2-dev

Solution 3:[3]

Install dependencies for php

sudo apt-get install -y libbz2-dev sqlite3 libsqlite3-dev libssl-dev libcurl4-openssl-dev libjpeg-dev libonig-dev libreadline-dev libtidy-dev libxslt-dev libzip-dev

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SylvesterAbreuLoreto
Solution 2 T.Todua
Solution 3 Thomas Zhang