When compiling PHP extensions or installing applications like Phraseanet that interface with PHP, the system needs to locate php-config
, a crucial utility that provides compilation information about your PHP installation.
First, let's verify if php-config is installed:
which php-config || locate php-config
If nothing returns, you'll need to install the PHP development package:
sudo apt-get install php5-dev # For PHP 5
# Or for newer versions:
sudo apt-get install php-dev
After installation, php-config can typically be found in:
- /usr/bin/php-config
- /usr/local/bin/php-config
- /opt/lampp/bin/php-config (for XAMPP installations)
When running ./configure for Phraseanet, you'll need to specify the path explicitly:
./configure --with-php-config=/usr/bin/php-config
For multiple PHP versions, first check installed versions:
update-alternatives --list php
To ensure everything works correctly, test php-config output:
php-config --prefix
php-config --version
php-config --includes
If you still encounter issues:
- Check PHP CLI version matches your web server version
- Verify PHP development headers are installed
Here's a full example for Phraseanet:
sudo apt-get install php-dev
./configure --with-php-config=$(which php-config)
make
sudo make install
When compiling PHP extensions or installing PHP-dependent software like Phraseanet, you might encounter this common configuration error. The php-config script is crucial during compilation as it provides the necessary PHP installation details including:
- PHP extension directory
- Include paths
- Version information
- Library dependencies
First, let's find where PHP is installed on your Ubuntu system. The php-config script typically resides in one of these locations:
/usr/bin/php-config
/usr/local/bin/php-config
/opt/lampp/bin/php-config
(for XAMPP installations)
Run this command to search for it:
sudo find / -name php-config 2>/dev/null
If nothing shows up, you likely need to install the PHP development package.
For Ubuntu/Debian systems, install the appropriate package:
sudo apt-get install php5-dev # For PHP 5.x
sudo apt-get install php7.4-dev # For PHP 7.4
sudo apt-get install php8.1-dev # For PHP 8.1
After installation, verify the location:
which php-config
When running ./configure
for Phraseanet or any PHP extension, specify the path explicitly:
./configure --with-php-config=/usr/bin/php-config
If you're compiling a PHP extension:
phpize
./configure --with-php-config=/usr/bin/php-config
make
sudo make install
If you have multiple PHP versions installed (common with php-fpm setups), ensure you're using the correct php-config:
update-alternatives --config php-config
Select the appropriate version from the menu.
1. Permission Denied:
sudo chmod +x /usr/bin/php-config
2. Mismatched PHP Versions:
Verify your CLI and Apache PHP versions match:
php -v
And in Apache:
For custom PHP installations, you might need to specify additional paths:
./configure \
--with-php-config=/custom/path/to/php-config \
--with-apxs2=/usr/bin/apxs2 \
--with-mysql=mysqlnd
Remember to restart your web server after making changes:
sudo service apache2 restart