How to Create phpinfo page

What is phpinfo?

phpinfo function is used to check the current PHP configuration settings. Using phpinfo function we can check PHP compilation options, enabled PHP extensions, php version, server information etc. phpinfo page also helps to debug the PHP errors.


Is it safe to create phpinfo

Hackers can get the server and PHP information if you expose phpinfo publicly. Delete the phpinfo file after debugging is completed. Do the below steps to restrict access to phpinfo only for your IP address.


Restrict access to phpinfo

Allow access to phpinfo file only for your ISP IP address.

1. Go to website to get your ISP IP address

2. Create a .htaccess file and paste the below content to restrict access to phpinfo.php file

# Deny access to phpinfo.php

Order allow, deny
allow from [your-isp-ip-address]
Deny from all

your-ip-address = This should be replaced with your ISP ip address


How to create phpinfo file

1. Go to directory/website in which you wish to create phpinfo file

Command :
# cd /var/www/

2. Create a new file ‘phpinfo.php’ and paste the below content :

You can use ‘vi’ editor or ‘nano’ and paste the below content.


# vi phpinfo.php

<?php phpinfo(); ?>


How to create phpinfo page

How to create phpinfo page

3. Access the file phpinfo.php in the web browser

Example :

phpinfo page

phpinfo page

Don’t forget to delete the phpinfo.php file when you no longer need it.


Alternate way : How to create phpinfo page

1. Open a text editor in your PC and paste the below content


<?php phpinfo(); ?>


2. Save the file as info.php

3. Upload it to your server/website using FTP