Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This may seem trivial to some, but I have been developing on Windows all my life and only moved to Linux this week - all is new to me.

I've been following The following guide on how to install php extensions on Linux. It worked perfectly for the mbstring extension, however, when I tried to do the exact same for bz2 and curl, I would get the error: configure: error: Cannot find php-config. Please use --with-php-config=PATH

Has anyone encountered this error before and could shed some light in terms a rookie could understand? Both extensions came with the PHP 5.5 source. My commands used and their outputs are as follows:

Find php-config:

[Art@art ~]$ sudo find -name php-config

Confirm php-config exists:

[Art@art bz2]$ cd ~/php/scripts
[Art@art scripts]$ ls -ltr
total 48
-rw-r--r--. 1 Art  Art  4690 May 28 09:06 phpize.m4
-rw-r--r--. 1 Art  Art  4499 May 28 09:06
-rw-r--r--. 1 Art  Art  2070 May 28 09:06
-rw-r--r--. 1 Art  Art  1744 May 28 09:06 Makefile.frag
drwxr-xr-x. 3 Art  Art  4096 May 28 09:06 dev
drwxr-xr-x. 2 Art  Art  4096 May 28 09:06 apache
-rw-r--r--. 1 root root 4522 Jun 25 09:16 phpize
-rw-r--r--. 1 root root 2260 Jun 25 09:16 php-config
drwxr-xr-x. 2 Art  Art  4096 Jun 25 09:16 man1

phpize bz2

[Art@art scripts]$ cd ~/php/ext/bz2
[Art@art bz2]$ phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212

config and error

[Art@art bz2]$ sudo ./configure --with-php-config=~/php/scripts/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: Cannot find php-config. Please use --with-php-config=PATH

Running php-config:

Usage: /usr/local/bin/php-config [OPTION]
  --prefix            [/usr/local]
  --includes          [-I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local
/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib]
  --ldflags           []
  --libs              [-lcrypt   -lresolv -lcrypt -lrt -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm
 -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt ]
  --extension-dir     [/usr/local/lib/php/extensions/no-debug-zts-20121212]
  --include-dir       [/usr/local/include/php]
  --man-dir           [/usr/local/php/man]
  --php-binary        [/usr/local/bin/php]
  --php-sapis         [ apache2handler cli cgi]
  --configure-options [--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql]
  --version           [5.5.13]
  --vernum            [50513]
share|improve this question
Why are you running configure as root? Anyways, what do you get running php-config (you should get sth like this)? Also, check config.log. – Artefacto Jun 26 '14 at 9:43
I'm running it as root because otherwise it says I don't have the required permissions. I've appended the output of running php-config to the question – AM- Jun 26 '14 at 9:49

You need the devel package installed:

# yum install php-devel

which package includes /usr/bin/php-config. This is generally true for RH/CentOS components when you're planning on going off-piste and compiling your own stuff; the foo-devel package contains the necessary stuff to allow you to compile against foo. The separation is done so that those admins who aren't going to want to hand-build stuff don't have to have all the hooks installed.

Edit: I'm not saying you shouldn't build extensions from source; just that if you want to, you'll need php-devel. But what you say in your comment suggests that you're trying to rebuild the whole of PHP - in which case, you can't start with the extensions, you'll need to build the whole of PHP, starting with PHP.

If you can clarify what the minimum version of PHP you can live with is, there may be better routes to getting it than building it.

share|improve this answer
The reason I built from source is that yum doesn't have the most recent version of PHP, which we need for our source code to work. – AM- Jun 26 '14 at 11:04

I'd guess you're mismatching phpize and php-config. Make sure you're using both from the same installation. So if you configure php with some prefix $A, use:

./configure --with-php-config=$A/bin/php-config

BTW, you shouldn't be building bundled extensions with phpize. It will mostly work, but it's not guaranteed to (I tried the curl and bz2 extensions and those two do seem to work). You should instead rebuild php with --enable-<extension>=shared or --with-<extension>=shared (pass --help to configure to check which one).

Also, it's generally a good idea to use packages, for several reasons (easy removals, possibility to handle upgrades, no compiling necessary after the package has been built, and so on). It would also avoid the kind of mistakes you get from having multiple versions installed. This relatively easy to do with fpm:

sudo yum install ruby-devel rubygems; sudo gem install fpm
curl -L | tar xjf -
cd php-5.5.13/
./configure --prefix=/usr --disable-all --enable-mbstring=shared # edit config line to your taste
make -j8
make install INSTALL_ROOT=root
# you can optionally strip the binaries at this point
# a simple would be find root | xargs strip
cd root
# add dependencies with -d foo if necessary, for instance -d libcurl
fpm -s dir -t rpm -n php -v 5.5.13 .
sudo yum localinstall php-5.5.13-1.x86_64.rpm
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.