Question

While trying to compile Xcache version 3.x for MAMP, phpize looks for a previous version of PHP which comes with Xcache 2.x

pwd: /Applications/MAMP/bin/php/php5.5.3/xcache-3.1.0

$ phpize
grep: /Applications/MAMP/bin/php/php5.4.19/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.4.19/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.4.19/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  

The issue appeared when I upgraded to OSX 10.9.

Was it helpful?

Solution

Building XCache against MAMP

  1. setup command line
  2. download and configure php source
  3. build xcache

Setup command line

You need to configure Bash to use the correct php command. Since you wanted to build against MAMP with 5.5.3 you can run the following command on your prompt:

$ export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH

You'll also want to add the above to ~/.bashrc to ensure future sessions use the correct php command — append to .bashrc:

$ echo 'export PATH=/Applications/MAMP/bin/php/php5.5.3/bin:$PATH' >> ~/.bashrc

Now when you run:

$ which php

You should see: /Applications/MAMP/bin/php/php5.5.3/php

Download and configure php source

Download the php5.5.3 source from http://www.php.net/releases/. MAMP does not include the PHP source, so you have to provide and configure it when building extensions from source.

Extract the archive and rename the folder to simply php and place it at /Applications/MAMP/bin/php/php5.5.3/include/ — meaning you should now have the path /Applications/MAMP/bin/php/php5.5.3/include/php/.

When you run:

$ /Applications/MAMP/bin/php/php5.5.3/include/php/configure

You should see a bunch of output. If you see an error double check you copied the source to the right location.

Now you can start building extensions against PHP 5.5.3.

Note: You may have to create the include folder

Since MAMP doesn't ship with source code they chose to omit the include folder — go ahead and create it since it's the conventional place to find php's source code when building extensions from source.

If you had a compiled version of php5.x located at /path/to/php5.x/ then the php source code should be found at /path/to/php5.x/include/php/.

Build XCache from source

After downloading the XCache source code decompress the archive and cd into it:

$ cd /path/to/xcache-source-code

Assuming you have downloaded xcache-3.1.0 into OSX's Downloads folder you can run this:

$ cd ~/Downloads/xcache-3.1.0

From within the XCache source code folder run these commands to build and install the Xcache extension:

$ phpize
$ ./configure --enable-xcache --with-php-config=/Applications/MAMP/bin/php/php5.5.3/bin/php-config
$ make 
$ make install

If everything was successful you will see xcache.so in your extensions directory.

Now you can enable the extension by adding extension=xcache.so to your php.ini. If you're using MAMP Pro it's important to edit php.ini via File > Edit Template > php.[version].ini — otherwise if you're using Basic you can run this one-liner:

$ open -a TextEdit `php -i | grep 'Load.*Config.*File.*=>' | sed s/'.* => '/''/`

Now, in php.ini search for the other "extension" directives and add extension=xcache.so to the list.

Check that it's installed by running:

$ php -i | grep xcache

You should see Xcache's settings. When you restart MAMP XCache will be enabled.

Hat tip to JT.

With 5.5.3 disable Zend OPcache

MAMP 2.2 ships with Zend OPcache enabled for PHP 5.5.3. This could cause problems for XCache.

If you use XCache make sure to disable Zend OPcache. In php.ini search for *[OPcache] and comment out the line:

zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/…/opcache.so"

like

;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/…/opcache.so"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top