How to Hide PHP Version (X-Powered-By)

Hide PHP Version
When your PHP processes php scripts, it displays the version and information. This article will help you learn how to hide PHP version.

How to hide PHP version information and Why? By default, when your PHP processes php scripts, it adds the “X-Powered By” and displays the version number and information. Like Apache, it is not good to expose your PHP information to the public. Please follow the below steps to hide it from the public.
Find your main PHP configuration file.

php -i | grep php.ini

 

You will get the location of your main php.ini file from this. Edit the file, and you can see the below lines.

vim /etc/php.ini
---
expose_php = on
---

 

Edit it as follows.

expose_php = off

 

Restart Apache

/etc/init.d/httpd restart

 

So that’s how you disable PHP version information. If you want to check the working, execute “curl -I http://yourdomain.com” in your shell before and after making the changes, and you can see the difference. If you check the header before making the changes, you can see something like the example given below.

HEAD http://yourdomain.com/index.php
200 OK
Connection: close
Date: The date goes here
Server: Apache
Content-Type: text/html; charset=UTF-8
Client-Date: Client date here
Client-Peer: Client IP here
Client-Response-Num: 1
X-Powered-By: PHP/5.x.x ( PHP version here )

 

After making the changes, you can see it’s no longer showing the PHP version. Actually, this won’t prevent hacking. But attackers won’t easily see what PHP version you have installed in your server. So this is something you have to do if you are concerned about the safety of your server.
If you want to disable Apache header information, please follow the steps mentioned in the article – How to Disable Apache Header Information: Easy Steps.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Linux Management Services

Focus on your business, and let us take care of your Linux Servers!
From what you are reading, it seems you are interested in Linux and related technologies. If you have a moment to spare, please take a look at our Linux Management Services plan, which might interest you even more!
Linux Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

Introducing - WPHealers!

Complete WordPress Management, 24x7 Support & White Label Agency Plans!

WordPress migration service, security, white-label reseller services and lot more! Grab the introductory deals now!

WPHealers

ServerHealers uses cookies.