I’m trying to use the builtin PHP in MacOS Catalina 10.15 by compiling the ZIP extension by myself.

In the new MacOS Catalina, the phpize tool is no longer usable since inside it contains an invalid path to the PHP libraries. The volume /usr is mounted read-only, making all the methods used in the past invalid.

I installed Xcode 11 from the AppStore.

Then I created another phpize that references Xcode by copiyng it to my Desktop

cp /usr/bin/phpize ~/Desktop/

then opened it for edit with vim

vim ~/Desktop/phpize

and modified line 8 as follows

includedir = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php"

Then, downloaded php-7.3.8, the same PHP version built-in on MacOS Catalina 10.15.

After have unpacked the archive file in the Downloads folder, I opened the Terminal up to its folder

cd ~/Downloads/php-7.3.8/ext/zip

Once inside, launched the customized phpize in order to prepare the ZIP extension to configure


The extension is now configurable. I launched configure with additional path to the required zlib

sudo ./configure --with-zlib-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/

The next step would be compile and install, but I’m still getting the error php.h file not found

make && make install

Maybe there’s still a wrong path somewhere...

  • Look at your Makefile. Might need to manually update some path there. Oct 14, 2019 at 20:10

1 Answer 1


You can use the CPPFLAGS to point make to the right /usr/include, which is located inside Xcode.app :


make CPPFLAGS="-I${INCLUDE_PATH}/php -I${INCLUDE_PATH}/php/main -I${INCLUDE_PATH}/php/TSRM -I${INCLUDE_PATH}/php/Zend -I${INCLUDE_PATH}/php/ext -I${INCLUDE_PATH}/php/ext/date/lib"

Also note, when editing phpize, there should not be spaces around the legal sign (=).


To address the followup comment, make install will also fail because it can't move the extension to the right place. But you still need to run the command as it will sign the *.so file.

Once make install is run, move the executable somewhere safe. I use /usr/local/php/extensions.

For example with Xdebug (change the .so name to the name of your extension):

sudo mkdir -p /usr/local/php/extensions
sudo cp $(php-config --extension-dir)/xdebug.so /usr/local/php/extensions

Then you edit the PHP configuration to enable your extension sudo nano /etc/php.ini by adding the necessary lines at the bottom (don't know the exact line for zip).

One this is done, restart the built-in server to be sure :

sudo apachectl restart

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .