What is the purpose of the php.ini file, and which settings are most critical for production security?

Last updated 15 June 2026

  • php.ini is PHP's main runtime config, loaded at startup (separately for CLI and web SAPIs like FPM). It controls errors, resource limits, extensions, uploads, and sessions.

  • Stop information leakage: display_errors = Off with log_errors = On, and expose_php = Off.

  • Restrict dangerous features: disable_functions (e.g. exec), allow_url_include = Off, open_basedir, and secure session cookies (cookie_httponly, cookie_secure, use_strict_mode).

  • https://www.geeksforgeeks.org/php/installing-php-and-configuring-it-on-ubuntu-14-04-trusty/
  • https://interview.sughara.in/topics/php
All PHP interview questions