Show the PHP configuration with phpinfo

Published

Updated

ℹ️

Debug PHP configuration details.

A file with <?php phpinfo(); in the root path shows the PHP version, extensions, settings and ENV vars in the browser. Delete it right after use, it exposes secrets.

Show phpinfo

phpinfo() prints the PHP version, the loaded extensions with their versions, all ini settings and the environment variables of the running PHP.

  1. Create a file info.php in the root path, web or public depending on the software.
  2. Put this line in it:
    <?php phpinfo();
    
    php
  3. Open https://example.com/info.php in the browser.
  4. Delete the file when done.

To see only one part, pass a constant, such as phpinfo(INFO_MODULES) for the extensions. See phpinfo on php.net.

phpinfo in the terminal

Over SSH, php -i prints the same data as text. It shows the command line settings, which can differ from the settings of web requests. For a single value, use php -r 'echo ini_get("memory_limit");'.

phpinfo in a CMS

Craft CMS shows it in the control panel under Utilities → PHP Info. WordPress shows server details under Tools → Site Health → Info.

Keep phpinfo private

phpinfo shows every ENV var, including the database password and API keys. Never leave an info.php file on a public site. Bots request info.php and phpinfo.php on every domain. Delete the file right after use, or put the environment behind password protection while it exists. See ENV var security.

Change PHP settings in the PHP settings of the environment.

Frequently asked

Is it safe to leave a phpinfo file on a website?

No. phpinfo shows all environment variables, including database passwords and API keys, and bots scan for info.php files. Delete the file right after use.

#

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗