The Illusion of the Missing php.ini on Ubuntu
When you attempt to modify a runtime directive like upload_max_filesize in PHP, expecting an immediate effect after renaming your configuration files, it is natural to be confused by the output showing (none) for the "Loaded Configuration File." This often indicates that the web server or CLI interpreter is running without a specific, explicit php.ini file loaded from your standard locations.
The core issue here is not that the configuration file is missing entirely, but rather that PHP has fallen back to its built-in default values because it could not locate a valid configuration file in the expected paths. On Ubuntu systems, particularly when running alongside Apache or using the CLI, multiple copies of php.ini often exist. You may find one in /etc/php/7.x/apache2/, another in /etc/php/7.x/cli/, and sometimes even in /etc/php/7.x/fpm/. Renaming these files to .old is a valid troubleshooting step, but it does not explain why the active configuration remains empty unless you have missed the actual file being read by your specific service.
To determine exactly which php.ini is activeâor if none is loadedâyou must look beyond the standard directories and inspect the runtime output. When you call phpinfo() or run php -i, the "Loaded Configuration File" section will explicitly state the path of the file currently in use, or it will display (none). If it displays (none), PHP is using its internal defaults defined in the source code. This happens frequently when a custom configuration file exists but lacks the proper directive syntax to override the default behavior, or if the user running the web server (usually www-data on Ubuntu) does not have read permissions for the file you edited.
A common pitfall occurs when editing the wrong php.ini. Developers often assume that modifying the file in /etc/php/7.x/apache2/ will affect Apache requests, which is correct. However, if your application runs under a different SAPI (Server API) or if the Apache module mod_php is not properly linked to that specific version's configuration directory, changes will be ignored. In such cases, the service might be reading from /etc/php/7.x/fpm/pool.d/www.conf, which includes an include directive pointing to a different configuration file entirely.
To resolve this without relying on trial and error, you should inspect the actual loaded settings directly from the command line. Execute the following command to see the exact path:
php -i | grep "Loaded Configuration File"
If this returns (none), you need to create a new php.ini file in /etc/php/7.x/apache2/. Simply copying one from another location is insufficient; the file must be valid and readable by the Apache process. Once the file exists, ensure the directory permissions are set correctly:
chown root:www-data /etc/php/7.x/apache2/php.ini
chmod 644 /etc/php/7.x/apache2/php.ini
After creating or fixing the configuration file, restart your web server to apply the changes:
sudo systemctl restart apache2
If you are managing a Laravel application or any modern PHP stack, consider using .env files and environment-specific configuration rather than relying solely on global php.ini directives. For more granular control over upload limits without touching global settings, Apache allows you to define these directly in the virtual host configuration file using <Directory> blocks or .htaccess rules, provided AllowOverride FileInfo is enabled.
For developers seeking deeper insights into PHP configuration management on Ubuntu, resources like https://laravelcompany.com offer valuable guidance on structuring modern PHP applications and handling environment-specific configurations effectively. Understanding the distinction between SAPIs and their respective configuration files is essential for maintaining a robust deployment where changes take effect immediately and predictably.