{"id":5921,"date":"2015-02-11T23:49:06","date_gmt":"2015-02-11T15:49:06","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=5921"},"modified":"2023-04-28T09:47:18","modified_gmt":"2023-04-28T09:47:18","slug":"how-to-hide-php-version-in-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-hide-php-version-in-linux\/","title":{"rendered":"How to Hide PHP Version in Linux"},"content":{"rendered":"<p>PHP is a popular scripting language used to develop web applications. However, displaying the PHP version on a website can be a security risk as it reveals valuable information to attackers. By hiding the PHP version, you can make it more difficult for attackers to exploit vulnerabilities in your PHP installation.<\/p>\n<p>In this guide, we will show you how to hide the PHP version on Linux.<\/p>\n<p>Before:<\/p>\n<pre>\r\n[root@centos66 ~]# curl -I https:\/\/webhostinggeeks.com\/howto\/\r\n<\/pre>\n<pre>\r\nHTTP\/1.1 200 OK\r\nServer: nginx\r\nContent-Type: text\/html; charset=UTF-8\r\nVary: Accept-Encoding\r\n<strong>X-Powered-By: PHP\/5.3.3<\/strong>\r\nX-Pingback: https:\/\/webhostinggeeks.com\/howto\/xmlrpc.php\r\nDate: Wed, 11 Feb 2015 14:10:43 GMT\r\nX-Page-Speed: 1.9.32.2-4321\r\nCache-Control: max-age=0, no-cache\r\n<\/pre>\n<p>After:<\/p>\n<pre>\r\n[root@centos66 ~]# curl -I https:\/\/webhostinggeeks.com\/howto\/\r\n<\/pre>\n<pre>\r\nHTTP\/1.1 200 OK\r\nServer: nginx\r\nDate: Wed, 11 Feb 2015 15:38:14 GMT\r\nContent-Type: text\/html; charset=UTF-8\r\nVary: Accept-Encoding\r\nX-Pingback: https:\/\/webhostinggeeks.com\/howto\/xmlrpc.php\r\nDate: Wed, 11 Feb 2015 14:10:43 GMT\r\nX-Page-Speed: 1.9.32.2-4321\r\nCache-Control: max-age=0, no-cache\r\n<\/pre>\n<h2>Step 1: Locate the PHP Configuration File<\/h2>\n<p>The first step is to locate the PHP configuration file. Depending on your Linux distribution, the location of this file may vary. In most cases, you can find it at:<\/p>\n<pre>\/etc\/php.ini<\/pre>\n<h2>Step 2: Edit the PHP Configuration File<\/h2>\n<p>Once you have located the PHP configuration file, you need to edit it. Open the file in your preferred text editor:<\/p>\n<pre>sudo nano \/etc\/php.ini<\/pre>\n<p>Find the following line:<\/p>\n<pre>expose_php = On<\/pre>\n<p>Change it to:<\/p>\n<pre>expose_php = Off<\/pre>\n<p>Save the changes and exit the editor by pressing Ctrl + X, then Y, and finally Enter.<\/p>\n<h2>Step 3: Restart the Web Server<\/h2>\n<p>Finally, you need to restart the web server for the changes to take effect. The command to restart the web server depends on the web server you are using. If you are using Apache, run the following command:<\/p>\n<pre>sudo service apache2 restart<\/pre>\n<p>If you are using Nginx, run the following command:<\/p>\n<pre>sudo service nginx restart<\/pre>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo nano \/etc\/php.ini<\/span> &#8211; Open the PHP configuration file in nano text editor<\/li>\n<li><span class=\"fw-bold\">sudo service apache2 restart<\/span> &#8211; Restart Apache web server<\/li>\n<li><span class=\"fw-bold\">sudo service nginx restart<\/span> &#8211; Restart Nginx web server<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this guide, we have shown you how to hide the PHP version on Linux. By following these steps, you can prevent attackers from discovering the PHP version running on your web server, making it harder for them to exploit vulnerabilities. It is important to note that hiding the PHP version is just one of many security measures you should take to secure your web server. We hope this guide has been helpful to you. If you have any comments or suggestions for improvements, please feel free to share them below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP is a popular scripting language used to develop web applications. However, displaying the PHP version on a website can be a security risk as it reveals valuable information to&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6195,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1025],"tags":[1646,1744],"class_list":["post-5921","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-php","tag-security"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=5921"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/5921\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6195"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=5921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=5921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=5921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}