Tools
Log in
English

Learn to codeSecurity check

PHP version shown in headers

AdvisoryP05PHP servers (Linux and Windows)

Turn off expose_php so the X-Powered-By header does not reveal your PHP version.

What is the risk

With expose_php on, every response carries X-Powered-By: PHP/8.x.y.

Attack tools use that version to pick vulnerable servers. Hiding it does not fix bugs, but you show up in fewer automated scans.

How to check

Linux

curl -sI https://example.com/ | grep -i x-powered-by

Replace example.com with your site.

Windows PowerShell (admin)

(Invoke-WebRequest https://example.com/ -Method Head -UseBasicParsing).Headers['X-Powered-By']

How to fix

php.ini

expose_php = Off

Edit php.ini and restart PHP-FPM, Apache or IIS.

nginx config

fastcgi_hide_header X-Powered-By;

To strip it in nginx as well, add this to the server block, then sudo nginx -t and sudo systemctl reload nginx.

Apache config

Header unset X-Powered-By

Needs mod_headers (on Debian and Ubuntu: sudo a2enmod headers).

How to prevent it

  • Keeping PHP up to date matters more than hiding the version (P02).
  • Trim the Server header too: server_tokens off; in nginx, ServerTokens Prod in Apache.

Check again after fixing

Linux

curl -sI https://example.com/ | grep -i x-powered-by

No output means it is hidden.

Run the downloaded check again and make sure this item passes.

Security check home