Where is the php.ini file on a Linux/CentOS PC?

Where is the php.ini file on a Linux/CentOS PC?

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Where is the php.ini file on a Linux/CentOS PC?

Finding the php.ini configuration file on a modern Linux distribution like CentOS or a Linux Mint desktop isn't as straightforward as simply grepping /etc. The answer depends entirely on how PHP was compiled and which SAPI (Server API) you are targeting. If you are struggling to locate your active configuration, it is likely because your environment uses php.ini-development or php.ini-production, or worse, a virtual ini file that doesn't exist as a physical disk entry.

The Role of the CLI vs. Web Server

On a standard CentOS installation using EPEL or default repositories, PHP often ships with a single master configuration file located at /etc/php.ini. However, this is rarely the case in production environments today. Modern setups frequently split configurations into php.ini-development and php.ini-production. The active file depends on the environment variables set during the build process.

If you are running PHP from the command line (CLI), check for a file at /etc/php.ini, /etc/php/8.x/cli/php.ini, or sometimes just inside your home directory under ~/.php.ini. To verify which one is actually loaded, run:

php -i | grep "Configuration File"

This command outputs the path to the currently active php.ini. If it returns none, your configuration relies on .env files or directives defined in your web server configuration rather than a static ini file. This is common with PHP 7.3+ and often preferred for security, as it prevents accidental exposure of settings via display_errors = On.

The Apache Module Scenario (mod_php)

If you are running on CentOS with Apache and the libphp module installed (often referred to as mod_php), the initialization logic differs from CLI or FPM setups. In this architecture, Apache loads PHP before it can read the standard ini file. Consequently, Apache might ignore a global /etc/php.ini if specific overrides exist within the web server's own config directories.

You should inspect your Apache configuration for Include directives that pull in PHP settings. Look for files in /etc/httpd/conf.d/ or similar locations where .ini extensions are dropped into. A common pitfall is editing /etc/php.ini and assuming those changes take effect on the web server, only to find the settings ignored because Apache loaded a different initialization sequence first.

PHP-FPM and Virtual Ini Files

On many managed hosting platforms like zPanel (mentioned in your source material) or modern Dockerized environments, PHP runs as a FastCGI Process Manager (FPM). Here, the system often uses "virtual" ini files. These are not single physical files but rather collections of directives defined across multiple locations.

To find the effective configuration for FPM, check /etc/php/8.x/fpm/conf.d/. This directory usually contains individual .ini files that get concatenated in alphabetical order at runtime. If you need to change a setting like memory_limit, you can drop a file named 10-memory-limit.ini into this directory.

Crucially, the main FPM configuration resides at /etc/php/8.x/fpm/php.ini. Unlike CLI, where php -i works seamlessly, verifying the web-facing configuration requires checking the FPM-specific path or using:

php-fpm -i | grep "Configuration File"

However, note that php-fpm itself might not be installed on your CLI system if you are only running Apache directly.

Why You Can't Find It

If you have checked /etc/php.ini and found nothing, or if the file exists but seems to lack your changes, consider these two realities:

  1. Symbolic Links: The system might be using a symbolic link pointing to a location outside of /etc, such as /usr/local/etc/php/.
  2. Compiled-in Defaults: Some directives are compiled into PHP itself and cannot be changed via php.ini at all.

Always trust the output of phpinfo() or php -i over your assumptions about file locations. If you are using a framework like Laravel, the application directory might contain its own php.ini if the server is configured to prioritize local settings, though this is less common on standard Linux installs.

For developers managing production servers where stability and security are paramount, relying solely on a single monolithic php.ini is becoming an outdated pattern. Instead, utilizing separate ini files for different SAPIs (CLI, FPM) and leveraging the web server's own config directories offers better isolation and clarity. If you need enterprise-grade PHP management tools that handle these complexities automatically, resources like https://laravelcompany.com often discuss modern deployment strategies for Laravel applications on Linux.

Our network