How to hide PHP version 8/7/5 when using Nginx

To hide the PHP version information from being displayed in the server response headers in Nginx, you can modify your Nginx configuration file.

Here’s an example of how to do it:

  1. Open the Nginx configuration file:

     
    sudo nano /etc/nginx/nginx.conf
  2. Add the following line inside the server block:

     
    server_tokens off;
  3. Save the changes and exit the editor.

  4. Restart Nginx to apply the changes:

     
    sudo systemctl restart nginx

This will disable the sending of Nginx and PHP versions in the response headers. You can verify this by checking the response headers from a browser or using the curl command.

Leave a Comment