"Cannot find config.m4." while running phpize in the installation of apd using pecl
Asked Answered
T

2

13

I'm trying to get access to rename_function in PHP, and for that I need PECL APD. I'm running Ubuntu 14.04 LTS.

I'm trying to run sudo pecl install apd, but I'm getting:

downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
15 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of
the module

If the command failed with 'phpize: not found' then you need to install php5-dev package. You can do it by running 'apt-get install php5-dev' as a root userERROR: `phpize' failed

Should I be running this command from a certain directory?

This time I tried it with verbose options turned on, in case there is a clue in the logs:

sudo /usr/bin/pecl -vvvvv install apd
Warning: file_exists(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1518

Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528

Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528
Downloading "http://pecl.php.net/get/apd-1.0.1.tgz"
downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/LICENSE /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: rename /usr/share/php/doc/apd/.tmpLICENSE /usr/share/php/doc/apd/LICENSE
adding to transaction: installed_as LICENSE /usr/share/php/doc/apd/LICENSE /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/README /usr/share/php/doc/apd/.tmpREADME
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpREADME
adding to transaction: rename /usr/share/php/doc/apd/.tmpREADME /usr/share/php/doc/apd/README
adding to transaction: installed_as README /usr/share/php/doc/apd/README /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprofp /usr/bin/.tmppprofp
+ chmod +x /usr/bin/.tmppprofp
adding to transaction: chmod 775 /usr/bin/.tmppprofp
adding to transaction: rename /usr/bin/.tmppprofp /usr/bin/pprofp
adding to transaction: installed_as pprofp /usr/bin/pprofp /usr/bin /
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprof2calltree /usr/bin/.tmppprof2calltree
+ chmod +x /usr/bin/.tmppprof2calltree
adding to transaction: chmod 775 /usr/bin/.tmppprof2calltree
adding to transaction: rename /usr/bin/.tmppprof2calltree /usr/bin/pprof2calltree
adding to transaction: installed_as pprof2calltree /usr/bin/pprof2calltree /usr/bin /
15 source files, building
building in /tmp/pear/temp/pearf7LGca
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

If the command failed with 'phpize: not found' then you need to install php5-dev packageYou can do it by running 'apt-get install php5-dev' as a root userrolling back 12 file operations
+ rm /usr/share/php/doc/apd/.tmpLICENSE
+ rm /usr/share/php/doc/apd/.tmpREADME
+ rm /usr/bin/.tmppprofp
+ rm /usr/bin/.tmppprof2calltree
ERROR: `phpize' failed

Warning: unlink(/tmp/glibctestRdKE0K): No such file or directory in System.php on line 214

Warning: unlink(/tmp/pear/temp/pearf7LGca): No such file or directory in System.php on line 214
Timothea answered 7/7, 2014 at 14:27 Comment(2)
Did you bother reading the last line of that error message? It tells you what the probable solution is.Michaelmas
I did. apt-get install php5-dev was executed successfully and phpize exists in /usr/bin. I don't understand "Make sure that you run '/usr/bin/phpize' in the top level source directory of the module", however.Timothea
S
17

This will be a short summary of everything to is a precondition to run APD as a PHP profiler, I hope it will help your needs. This summary applies for PHP 5.6.2 APD 1.0.1 and might be incorrect for other versions.

First of all do not start it if you didn't ensure these two:

  • Deactivate Zend platform or any other PHP optimizer. In general you need to disable all Zend extensions.
  • Install a debugging enabled version of PHP (--enable-debug)

If you have a working PEAR setup you need to setup APD like in this article. Don't forget to try out distribution packages either. Otherwise APD's build as following:

  • Extract tarball.
  • Change directory in tarball.
  • Run <apache root>/bin/phpsize
  • Run ./configure (Add --with-php-config=<apache root>/bin/php-config if configure fails.)
  • Compile and install everything using
    make
    make install
    
  • Edit php.ini and add at least
    zend_extension=/apd.so
    apd.statement=1
    apd.tracedir=/tmp/apd-traces
    
  • Create the output directory specified in php.ini

Now you'll need to restart Apache but before you do, check that the APD extension works fine. To do simply run PHP

/bin/php

No warning should be given if extension is loaded properly. If you get error message something like the "apd.so" extension couldn't be loaded there is a problem. Check if you compiled against the correct Apache/PHP version and using the same right now.

If PHP doesn't complain about anything enter:

<?php phpinfo(); ?>

and check for some lines about APD. If you find them you are done.

You'll also need some traces so to start tracing you need to your Apache to allow the PHP module to load APD. Next you'll need to identify the script to trace. Add the APD call at the top of the script:

apd_set_pprof_trace();

Then make some requests and remove the statement again to avoid causing further harm. Now have a look at the trace directory. You should find files with a naming scheme of pprof[0-9]*.[0-9] here. Decode them using the pprofp tool from your APD source tarball. Example:

/bin/php /pprofp -u 

Redirect stdout if necessary. Use -t instead of -u (summary output) to get calling trees. When you create traces with -t you get a summary output too, but it doesn't contain the per-call durations. I suggest to always create both a call tree and a summary trace.

Hope that helps, I recommend you hardly to read the link mentioned above.

EDIT:

The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4). See this for more info.

Snap answered 11/7, 2014 at 5:5 Comment(5)
Thanks for this write up! I read the article on APD and it sounded easy to install, but I had no luck. I unpacked pecl.php.net/get/apd-1.0.1.tgz, ran phpize on it (which works), and ran configure. But when I run make or make install, I get several pages of errors, like "/usr/include/php5/Zend/zend_globals_macros.h:37:33: error: 'struct _zend_compiler_globals' has no member named 'extended_info' # define CG(v) (compiler_globals.v)". I don't think Zend platform installed. How do I install a debugging enabled version of PHP? (Mine doesn't offer --enable debug)Timothea
I'm just guessing, because its one line of your error message, so if you used function_entry then change it to zend_function_entry, cause function_entry is removed in php 5.4. The error message says that APD cannot compile on your version of PHP. Here is a patch that should fix your problem. If your PHP version doesn't allow you the debug, try to install DBG Hope that helps.Snap
To people from future: I was able to build apd1.0.1 against php5.4 with this patch.Sixth
@Sixth I have used this patch with PHP 5.6 and i have errors like that. php_apd.c:984:23: error: expected expression before '=' token CG(compiler_options) = CG(compiler_options) | ZEND_COMPILE_EXTENDED_INFO; Do you have any ideas how to resolve that ?Regardless
@MichalOlszowski The patch is for 5.6.2, probably 5.6 doesn't compile with CG(extended_info) = 1;, so change that line in the patch to: CG(compiler_options) |= ZEND_COMPILE_EXTENDED_INFO; and run the patch like that. (It's located at the end of the patch file, under "Zend Extension Functions" section.) Hope that works!Snap
R
0

As per error:

If the command failed with phpize: not found then you need to install php5-dev package.

You can do it by running apt-get install php5-dev as a root user

I think you should install module development for PHP via:

sudo apt-get install php5-dev

This should provide you with phpize binary necessary to compile the Pecl extension sources. And make sure it's in your PATH.

Regurgitate answered 11/4, 2016 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.