How to hide PHP 5/7 version when using Nginx

ht‮t‬ps://www.lautturi.com
How to hide PHP 5/7 version when using Nginx

To hide the version of PHP when using Nginx, you can use the "expose_php" directive in the PHP configuration file. This directive controls whether the PHP version number is included in the "X-Powered-By" header field in HTTP responses.

To hide the PHP version, follow these steps:

  1. Open the PHP configuration file, typically located at "/etc/php/php.ini" or "/etc/php7/php.ini".

  2. Locate the "expose_php" directive and set its value to "off":

expose_php = off
  1. Save the configuration file and restart the Nginx server by running the following command:
systemctl restart nginx

(Note: the exact command to restart Nginx may vary depending on your system.)

With this configuration, PHP will not include the version number in the "X-Powered-By" header field of HTTP responses.

Note: Hiding the version of PHP can help to protect against certain types of attacks, but it is not a substitute for proper security measures such as keeping the server and its software up to date and configuring firewall rules to restrict access to the server.

Created Time:2017-10-28 21:39:03  Author:lautturi