How to create a phpinfo page?

Your web server's current PHP configuration parameters are shown on a phpinfo page. In this article, we'll show you how to create a phpinfo.php page and how to use it later.

Updated: 27 Dec, 22 by Susith Nonis 7 Min

List of content you will read in this article:

Your web server's current PHP configuration parameters are shown on a phpinfo page. The information on a phpinfo page would be very useful for site planning and troubleshooting if your website were created in PHP.

In other words, the phpinfo function allows web server administrators and PHP developers to view details about their PHP installation rapidly.

This can help with debugging, identifying the installed version of PHP, or viewing different configuration settings.

In this article, we'll show you how to create a phpinfo.php page and how to use it later.

Making a phpinfo page is easy if you know the fundamentals of File Transfer Protocol (FTP) and how to utilize an FTP client.

We've divided it into three simple steps in the sections below.

Please make a copy of phpinfo.php and place it on your server.

Start by launching your chosen text editor and generating this page. Add the following line of code to a new document:

phpinfo( );

Put one of the above parameters in between the parenthesis if you want to utilize it. Save the document as "phpinfo.php" after that. You can choose a different name if you'd like, but you must use the.php extension.

Next, launch FileZilla or another FTP software and use your FTP credentials to connect to your website server. 

Then, upload your updated public HTML folder's phpinfo.php file.

The phpinfo page has now been successfully added to your website. However, you'll need to know its location to view the page.

Open your browser and go to the phpinfo Page.

Your phpinfo page will be made public once uploaded to your server. This indicates that you can read it in a browser by adding /phpinfo.php to the end of the domain for your website.

This page will probably be lengthy if you opt to return all of your PHP information without using any parameters. 

By pressing CTRL or CMD + F on your computer, you can use the Find feature to find the precise information you're looking for.

Change the name of Your phpinfo Page.

Since your phpinfo.php file was put in your public HTML folder, as we specified in Step 2, it is now publicly accessible. 

The issue with this is that some of the data returned by the phpinfo() function is private and might be used maliciously by hackers to access your server.

Attackers may even use bots to look for phpinfo pages so that they may take advantage of them. Therefore, it is better to erase yours after you use it. Returning to your FTP client will allow you to achieve this.

Reconnect to your server after that, and then launch public HTML. Choose Delete by right-clicking on your phpinfo.php file.

To help protect it from hackers, some users rename their phpinfo page. Instead of "phpinfo," you might substitute a random string of letters and digits. 

The URL you use to access your phpinfo page will also change, so take note of it. This implies that to access your phpinfo page whenever you want, you'll need to remember the name you give it. 

However, since this isn't a surefire way to stop a security breach, it's preferable to make the page as needed and then erase it.

To create a phpinfo.php, first log into your cPanel. 

Open the File Manager option in your cPanel's Files area. Then, go to the directory you are using by navigating there. This is significant because distinct PHP settings can be defined for each folder. 

We are going to the "public HTML" folder since, in this case, we are looking at the PHP configurations for our primary domain.

To create a new file, select +File from the top menu.

Enter phpinfo.php when prompted for the file name (it can be named anything you want; however, phpinfo.php is simply a common name in this case).

In your list of files, look for the phpinfo.php file (it should have automatically updated). 

Edit it by right-clicking on it. Select "utf-8" from the drop-down list if you see a "Text Editor" prompt, then click Edit.

The phpinfo.php file should now include the following code:

<? phpinfo(); ?>

Finally, click on Save Changes.

After installing a LAMP server or LEMP server on a Linux system, it's typical to create a phpinfo.php page to check that PHP is operational and to confirm settings.

To make a new file, you can use nano, vim, or any other command line or GUI text editor. You can give it whatever name you like.

The phpinfo function must only be called once in this file, which may be done with the following line of code:

<?php phpinfo(); ?>

Exit now and save this document. It needs to be put where your web files are kept now. 

This may differ based on the Linux distribution you're running, the web hosting applications you've installed (such as Apache, NGINX, etc.), and how you've configured the system. 

However, the files are typically kept in the /var/www directory or one of its subdirectories.

You can visit the PHP file using a web browser once it has been put there. Use your server's fully qualified domain name or to visit the page.

This page generates a lot of data. You might send various options to this method if you're only interested in specific information to get a shorter output.

INFO GENERAL, for instance, provides some of the most fundamental details, including configuration line, location of php.ini and other.ini files, build date, web server and system type, as well as additional information.

This is it. The phpinfo function has all the necessary details about your server's configuration. 

Using PHP's interactive shell, you may get the same information if you directly access your server via the command line.

Creating a phpinfo page is frequently helpful for troubleshooting complicated PHP issues. 

This page will display data about the current configuration of the PHP installation on the server, including information about PHP compilation options, extensions, server information and environment (if compiled as a module), version, the PHP environment, paths, OS version data, master and local values of configuration options, HTTP headers, and the PHP License.

Phpinfo is frequently used to examine configuration settings and for accessible predefined variables on a specific system because every system is configured differently.

To create a phpinfo.php, follow this guide. However, it is strongly advised that you delete this file once done with it because of how much information it might reveal.

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.