When compiling PHP 5.3.1 from source with a custom configuration (shown below), many developers encounter the situation where the php.ini file isn't created during installation. This is particularly common when using non-standard compilation flags or when upgrading from older PHP versions.
./configure \
--with-fpm \
--with-libevent=shared,/usr/lib \
--with-mcrypt \
--with-zlib \
--with-curl \
--enable-mbstring \
--with-openssl \
--with-mysql \
--with-mysql-sock \
--with-gd \
--with-jpeg-dir=/usr/lib \
--enable-gd-native-ttf \
--without-sqlite
After installation, checking phpinfo() reveals:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: none
This indicates PHP knows where to look for the configuration file, but none exists in the specified directory.
The PHP source package includes sample configuration files that need to be manually copied to the correct location:
# Navigate to PHP source directory
cd ~/php-5.3.1
# Copy the development configuration (choose one)
cp php.ini-development /usr/local/lib/php.ini
# OR for production
cp php.ini-production /usr/local/lib/php.ini
If you prefer a different configuration path, you can:
- Recompile PHP with
--with-config-file-path=/your/custom/path
- Or create a symlink:
ln -s /custom/path/php.ini /usr/local/lib/php.ini
Create a test script (test.php):
<?php
phpinfo();
?>
After placing the php.ini file, reload your web server and check the output now shows:
Loaded Configuration File: /usr/local/lib/php.ini
- Ensure proper file permissions:
chmod 644 /usr/local/lib/php.ini
- For FPM installations, remember to restart both PHP-FPM and your web server
- Some directives (like extension_dir) may need adjustment in the new php.ini
When compiling PHP 5.3.1 from source with custom parameters, you might encounter a situation where the php.ini file isn't created in the expected location. Here's the configuration used in this case:
./configure \
--with-fpm \
--with-libevent=shared,/usr/lib \
--with-mcrypt \
--with-zlib \
--with-curl \
--enable-mbstring \
--with-openssl \
--with-mysql \
--with-mysql-sock \
--with-gd \
--with-jpeg-dir=/usr/lib \
--enable-gd-native-ttf \
--without-sqlite
The phpinfo() output shows:
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: none
This indicates PHP is looking in /usr/local/lib
for its configuration file, but none exists at that location after compilation.
PHP source distributions include two sample configuration files:
php.ini-development
- for development environmentsphp.ini-production
- for production servers
These are typically found in the PHP source directory. After extracting the PHP source, you can find them at:
cd php-5.3.1
ls -la php.ini-*
To resolve the issue, follow these steps:
# Copy the appropriate sample file
sudo cp php.ini-development /usr/local/lib/php.ini
# Or for production:
# sudo cp php.ini-production /usr/local/lib/php.ini
# Set correct permissions
sudo chmod 644 /usr/local/lib/php.ini
# Verify PHP can see the file
php -i | grep "Loaded Configuration File"
If you prefer to use a different location for php.ini, you can specify it during compilation:
./configure --with-config-file-path=/etc/php5 ...
Or set it at runtime using:
php -c /path/to/php.ini
If issues persist:
- Verify PHP is looking in the correct path with:
php --ini
- Check for multiple PHP installations:
which php php -v
- Ensure the php.ini file is readable by the PHP process