Web20 University

Where is the PHP ini file in Ubuntu?

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.