For Nginx
sudo nano /etc/nginx/nginx.confIn http block:
server_tokens off;
more_set_headers "Server: Hidden";(Install nginx-extras for more_set_headers)
For Apache
sudo nano /etc/apache2/conf-available/security.confSet:
ServerTokens Prod
ServerSignature OffFor PHP
sudo nano /etc/php/8.1/fpm/php.iniexpose_php = OffVerify
curl -I https://yourdomain.com | grep Server