php.ini Auditor
Your php.ini decides whether errors leak paths to visitors, whether remote files can be included, which functions any script can call, and whether a session cookie can be stolen. Read it before an attacker does.
A php.ini audit is a static review of a PHP server's configuration file — php.ini — checked line by line against known-good practice, without running PHP. Paste yours here and this auditor reads it in your browser — never uploaded — and flags display_errors leaking paths, allow_url_include opening remote file inclusion, missing disable_functions, no open_basedir, session cookies without HttpOnly or Secure, and unlimited memory and runtime, with a 0–100 score. The companion article php.ini security audit guide explains each check. Also see the Apache Config Auditor and the MySQL/Postgres Config Auditor.
Last updated:
1. Audit a config
Results
🔒 The audit runs entirely in your browser: the config is never uploaded, never stored, and never sent anywhere. A config names file paths, session storage and upload directories — that is exactly why it stays on your machine.
What a php.ini is
A php.ini is a flat list of settings, one directive = value per line: display_errors = Off, memory_limit = 128M, session.cookie_httponly = 1. ; and # start comments, values may be quoted (date.timezone = "UTC"), and [Section] headers group settings — [PHP], [Session], [opcache] — without changing what a directive means. A directive may appear more than once; the last value wins.
The directives fall into four concerns: what errors reveal (display_errors, display_startup_errors, log_errors, error_reporting), what code may do (allow_url_include, allow_url_fopen, disable_functions, open_basedir), how sessions are protected (cookie flags, strict mode, save_path), and what resources a script may consume (memory_limit, max_execution_time, max_input_vars, upload limits). The auditor reads all four with the same scoring.
Error handling is a trade-off, not a switch: display_errors = On shows errors to visitors — paths, SQL and stack traces — while log_errors = On with error_log set records them privately. Production wants the second: errors logged, never displayed. And error_reporting = E_ALL is the level that sees real errors; a level that excludes E_ERROR or E_WARNING is blind to the errors that matter most.
Two things the auditor deliberately does not check: the values PHP is actually running with — a php.ini on disk and the running server can disagree after a missed restart, and per-directory .user.ini files and runtime ini_set() calls can override it — and the PHP version itself: a removed directive set to On, like register_globals, tells you the install is ancient, but the auditor cannot tell you whether the version is still supported.
What this auditor does — and what it does not
It parses the config in your browser — directive lines, comments, quoted strings, section headers and duplicate directives — and runs 37 rules over the settings: error display and logging, error_reporting levels, remote file inclusion, uploads, disable_functions and disable_classes, open_basedir, every session cookie flag and strict mode, resource limits, removed directives, and the quiet defaults (timezone, assertions, opcache). Scoring starts at 100; each error deducts 10 (capped at 50), each warning 4 (capped at 28), each info 1 (capped at 10). Bands: 90+ Excellent, 70–89 Good, 50–69 Needs work, below 50 Poor.
It does not run PHP, read the running values, or check the server: it reads exactly the text you give it. It cannot see the values PHP is actually running with (phpinfo() / ini_get()), the PHP version and whether it is still supported, loaded extensions, the SAPI (CLI vs FPM vs mod_php), per-directory .user.ini overrides, or values set at runtime with ini_set(). A finding is a pattern, not a verdict — allow_url_fopen = On may be exactly what Composer needs. Read each finding with its evidence and decide with your context.
The broken demo is a small php.ini built to trip the rules on purpose — display_errors on, allow_url_include on, register_globals, magic_quotes_gpc and safe_mode on, uploads at 20M with post_max_size at 8M, no disabled functions, no open_basedir, session cookies without HttpOnly or Secure, unlimited memory and runtime — and scores 14 (Poor), with 27 findings across all three severities. The hardened demo is the same shape with every finding fixed, and scores 100.
Be honest about what a static audit cannot see
This audit reads text. It cannot see the values PHP is actually running with — a php.ini on disk and the running server can disagree after a missed restart, and .user.ini files and ini_set() calls can override it — nor the PHP version and whether it is still supported, loaded extensions, the SAPI, or real server exposure. A setting the file calls safe can be overridden at runtime, and a setting it calls risky can be locked down elsewhere.
And a high score is not a safe PHP install. The rules encode widely agreed practice — the PHP manual's runtime configuration and security chapters — but they are a checklist, not a penetration test. “No findings” means no risky pattern was found in this text — not that the server behind it is secure.
Key facts
| display_errors | Whether PHP prints errors to the visitor's browser. On in production leaks file paths, SQL fragments and stack traces — the first thing an attacker reads. Production wants display_errors Off and log_errors On with error_log set. |
| allow_url_include | Whether PHP may include remote files through include or require. On means a file-inclusion flaw can pull code from an attacker's server — remote code execution. It is almost never needed; allow_url_fopen is the safer, narrower switch for remote reads. |
| disable_functions | The list of functions PHP refuses to run: exec, shell_exec, system, passthru, popen and proc_open let a script run shell commands, so a single injection can become a shell. Disabling them is the cheapest hardening in php.ini — and some hosts need proc_open for legitimate tools, so check before you disable it. |
| open_basedir | The directory tree PHP scripts are allowed to touch. Set it and a script cannot read files outside it — /etc/passwd, other sites on the same host, the config itself. It has bypass history, so treat it as defence in depth, not a sandbox. |
| session.cookie_httponly | Whether the session cookie is hidden from JavaScript. On means a cross-site scripting hole cannot read the cookie and steal the session; Off means any injected script can. There is no legitimate reason to leave it Off. |
| error_reporting | Which error levels PHP reports: E_ALL sees everything, -1 is the same, and E_ALL & ~E_DEPRECATED drops only deprecation notices. A level that excludes E_ERROR or E_WARNING is blind to the errors that matter — set E_ALL and filter at the log, not at the source. |
| upload_max_filesize / post_max_size | The two caps that decide whether an upload works: upload_max_filesize caps one file, post_max_size caps the whole request. post_max_size must be larger than upload_max_filesize — when it is smaller, every upload at the cap fails, and the error message blames the file. |
| Format reference | PHP Manual — Runtime Configuration (ini.core) · PHP Manual — Security · PHP Manual — The configuration file |
Frequently asked questions
Why does the audit run in my browser instead of on a server?
Because a config can name things you do not publish: file paths, session storage, upload directories and internal hostnames. Sending that to a server to audit it would create the exact exposure the audit is meant to catch. Parsing it locally means the config never leaves your machine.
My config has findings — is my PHP unsafe?
Not necessarily. A finding is a pattern that matched, and some matches are intended: allow_url_fopen On for Composer, or a large upload_max_filesize for a media site. Start with the errors — display_errors On, allow_url_include On, the removed directives, post_max_size below upload_max_filesize — then the warnings, and treat the infos as a checklist of defaults worth setting explicitly.
display_errors Off but log_errors Off too — is that fine?
No — that is the worst of both: errors are hidden from visitors and lost to you as well. Production wants display_errors Off, log_errors On and error_log set to a file you actually read, with error_reporting E_ALL so nothing real is filtered out before it reaches the log.