When you're editing /etc/php5/apache2/php.ini
(as shown in phpinfo()) and changes aren't reflecting after Apache restart, we need to investigate several potential culprits. Here's how I approach this issue systematically:
Run this in browser and check:
- Loaded Configuration File - Confirm it matches the file you're editing
- Scan this dir for additional .ini files - Check if other ini files override your settings
- Additional .ini files parsed - List of all loaded configuration files
Several scenarios could cause this behavior:
# Check for multiple PHP installations
$ whereis php
php: /usr/bin/php /usr/bin/php5 /usr/lib/php /etc/php5 /usr/share/php5
# Verify which PHP version Apache is using
$ apache2ctl -M | grep php
PHP configuration follows this precedence order:
- Per-directory .htaccess files
- User INI files (
.user.ini
) - Additional ini files from
conf.d/
directory - Main php.ini file
Try these steps to ensure complete reload:
# Full Apache restart sequence
$ sudo service apache2 stop
$ sudo pkill -9 apache2
$ sudo service apache2 start
# Alternative method
$ sudo systemctl restart apache2.service
Some settings can be overridden in Apache config files:
# Check for PHP settings in Apache config
$ grep -r "php_value" /etc/apache2/
$ grep -r "php_flag" /etc/apache2/
# Example of Apache overriding php.ini
php_value memory_limit 256M
Test configuration changes directly:
# Check CLI PHP configuration
$ php -i | grep "Loaded Configuration File"
# Temporary test a configuration change
$ php -d memory_limit=512M -r "echo ini_get('memory_limit');"
If you've verified everything and still see no changes:
# Complete reinstall of PHP
$ sudo apt-get purge php5*
$ sudo apt-get autoremove
$ sudo apt-get install php5 libapache2-mod-php5
When working with PHP on Ubuntu (specifically version 9.04 with PHP 5.2 in this case), it's particularly frustrating when modifications to php.ini seem to have no effect - even when you're editing the correct file as indicated by phpinfo(). Let's systematically troubleshoot this issue.
First, confirm you're editing the right file by creating a PHP file with:
<?php phpinfo(); ?>
Look for the "Loaded Configuration File" line. If this shows /etc/php5/apache2/php.ini
but changes there don't apply, we need to dig deeper.
The warning about "Could not reliably determine the server's fully qualified domain name" is common and unrelated to our PHP configuration issue. However, let's ensure Apache is properly restarting:
sudo service apache2 restart # Or alternatively: sudo /etc/init.d/apache2 stop sudo /etc/init.d/apache2 start
Check for errors during restart that might prevent configuration reloading.
On Ubuntu systems, multiple PHP versions or installations can cause conflicts. Check if you have multiple PHP configurations:
ls /etc/php5/
Look for directories like apache2
, cli
, cgi
- ensure you're modifying the correct one for your web server.
Even if you're editing the right file, filesystem caching or permissions might prevent changes:
sudo chmod 644 /etc/php5/apache2/php.ini sudo chown root:root /etc/php5/apache2/php.ini
Then verify the changes took effect with:
ls -la /etc/php5/apache2/php.ini
Some Ubuntu PHP packages use additional configuration directories. Check for overrides in:
/etc/php5/apache2/conf.d/
Files here (usually symlinks) can override settings from php.ini. Temporarily rename these to test:
sudo mv /etc/php5/apache2/conf.d /etc/php5/apache2/conf.d.bak sudo service apache2 restart
If the issue persists, try these diagnostic commands:
# Check which PHP version Apache is using: apache2ctl -M | grep php # Verify the exact PHP module loaded: sudo apache2ctl -t -D DUMP_MODULES # Check for syntax errors in configuration: sudo apache2ctl configtest
As a last resort, consider reinstalling PHP packages:
sudo apt-get --purge remove php5 php5-common sudo apt-get install php5 php5-common sudo service apache2 restart
Remember to backup your php.ini before doing this.