Where is the PHP ini file in Ubuntu?
* Web 2.0 University is supported by it's audience. If you purchase through links on our site, we may earn an affiliate commision.
In Ubuntu and other Debian-based systems, the php.ini file is typically located in one of the following directories, depending on the PHP version and the server you are using:
- For Apache web server:
- PHP 7.x: /etc/php/7.x/apache2/php.ini
- PHP 8.x: /etc/php/8.x/apache2/php.ini
Replace x with the specific minor version number. For example, if you’re using PHP 7.4, the path would be /etc/php/7.4/apache2/php.ini.
- For PHP-FPM (FastCGI Process Manager):
- PHP 7.x: /etc/php/7.x/fpm/php.ini
- PHP 8.x: /etc/php/8.x/fpm/php.ini
Replace x with the specific minor version number.
- For PHP-CLI (Command Line Interface):
- PHP 7.x: /etc/php/7.x/cli/php.ini
- PHP 8.x: /etc/php/8.x/cli/php.ini
Replace x with the specific minor version number.
To find the exact location of your php.ini file, you can run the following command in your terminal:
php --ini
This command will display the configuration files used by the current PHP installation, including the location of the php.ini file. Note that this command shows the configuration file for the PHP-CLI version, which might be different from the one used by your web server.
Keep in mind that making changes to the php.ini file usually requires you to restart your web server (e.g., Apache or Nginx) or the PHP-FPM service for the changes to take effect.