Help Docs Performance Website Optimization How to use a phpinfo File

How to use a phpinfo File

Learn to create a phpinfo file to view your server's PHP configuration. Our step-by-step guide helps you find settings and securely remove the file.

A phpinfo file is a powerful tool that gives you a detailed snapshot of your server’s PHP environment. This guide will show you how to create one, use it to find important settings, and then securely remove it.

Introduction

Ever wonder which PHP extensions are enabled on your server, or what your server’s upload size limit is? A phpinfo page answers these questions and more. It scans your server’s current PHP settings and displays them on a single, easy-to-read webpage.

Creating this page is the quickest way to solve the problem of not knowing your server’s exact PHP configuration, which is essential for troubleshooting website issues or ensuring compatibility with new software.


Prerequisites

Before you start, you’ll need two things:

  • Access to your server’s file system. This can be through SSH, FTP, or your control panel’s File Manager.
  • Your website’s document root directory. This is the main folder where your website’s files are stored (often public_html or httpdocs).

Step-by-Step Instructions for Creating a phpinfo File

Follow these simple steps to create your phpinfo file.

  1. Connect to your server by logging in using your preferred method (SSH, FTP, or File Manager, if available).
  2. Go to your website’s document root directory. This ensures the file you create will be accessible from a web browser.
  3. Create a new file and name it phpinfo.php.
  4. Open the new file in a text editor (vim, or nano, for example) and add the following line of code that tells PHP to gather all its configuration information and display it:
    <?php phpinfo(); ?>
  5. Save your changes. That’s it! The file is now ready to be viewed as a phpinfo page via your website.

How to Access and Read the phpinfo Page

You can view the page using either your server’s IP address or your website’s domain name.

  • Via a Live Website: If your domain is active and pointing to your server, open your web browser and go to http://yourdomain.com/phpinfo.php (replace yourdomain.com with your actual domain name). This is the most direct method.
  • Before Your Website is Live (Using Your Hosts File): If you are still building or migrating your site, temporarily modify a special file on your local computer called the hosts file that tricks your computer into connecting your domain name with your new server’s IP address. For detailed instructions, please see our guide: Editing your DNS Hosts File.

The page displays a large amount of information. You can use your browser’s search function (Ctrl+F or Cmd+F) to quickly find specific settings. Here are a few key settings you might look for:

  • memory_limit: The maximum amount of memory a script is allowed to use.
  • upload_max_filesize: The maximum size of a file you can upload through your website.
  • post_max_size: The maximum size of data that can be sent in a single form submission.
  • Loaded Extensions: A full list of all active PHP modules (like curl, gd, or mysqli).

Best Practices & Security Warning

The information on the phpinfo page is very sensitive. It reveals your exact server software versions, file paths, and other configuration details. Leaving this file publicly accessible makes your server a much easier target for attackers.

For your security, you must delete the phpinfo.php file immediately after you are finished using it.
Simply log back into your server and delete the file from your document root. This is the most important step to keep your server secure.


Now that you know how to check your PHP configuration, you can use that information to manage your server more effectively.

Was this article helpful?