Key Takeaways
- A
phpinfo()page gives a complete overview of your PHP configuration, installed extensions, server environment, and more, helping you debug and verify settings. - Since the page exposes sensitive server information, always use it in a local or staging environment, restrict access, or delete it immediately after use.
- With just a single line of PHP code (
<?php phpinfo(); ?>), you can generate a detailed page that helps compare environments, troubleshoot issues, and confirm server settings.
Sometimes you just need to know exactly what PHP is doing under the hood. Maybe a specific plugin is acting up, or a script keeps crashing and you can’t figure out why. That’s usually when phpinfo becomes a lifesaver. It’s a native function that pulls every detail about your setup into one view like your version, active extensions, memory caps, and the exact config files running the show.
Before this was common, hunting down these details was a nightmare. You’d have to dig through hidden files or run a dozen different commands just to verify one setting. phpinfo puts all that data in a single table. It makes it much easier to fix bugs or just confirm that a server change you made actually worked.
In this blog, I’m going to walk you through how to build your own phpinfo page, how to read the messy results, and how to keep the file secure. Whether you’re testing locally, working on a live site, or checking settings on Cloudways, these steps will show you what’s happening behind the scenes so you can stop guessing.
What Is the phpinfo() Function and Why Use It?
At its core, phpinfo() is just a built-in command. When you run it, it builds a massive page showing the guts of your PHP environment. It covers the basics like your version and php.ini paths, but also dives into every tiny extension and server detail you might need.
Most people just run phpinfo() to see everything, but you can actually use specific “constants” to filter the noise if you’re looking for something specific:
- INFO_GENERAL: This is your “at-a-glance” view. It shows the PHP version, your OS, and the web server type. I use this first just to confirm I’m even on the right version.
- INFO_CONFIGURATION: Use this when you’re fighting with a setting. It shows your current directives and is the go-to for debugging php.ini issues.
- INFO_MODULES: If a plugin says it needs “ImageMagick” or “cURL,” this is where you check. It lists every installed extension and how they are configured.
- INFO_VARIABLES & ENVIRONMENT: These show your server and environment variables (like GET or POST data). It’s great for troubleshooting how data is moving through your server.
- INFO_ALL: This is the default. It spits out every single bit of data available.
The real value here is consistency. You can use this to compare your local dev setup against your live server. It stops those “it worked on my machine” headaches by letting you see if an extension is missing or if a memory limit is too low before you launch your code.
Managed PHP Hosting with Full Server Visibility
Cloudways managed PHP hosting gives you control over PHP versions, extensions, and settings so you can verify configurations easily and run PHP applications with confidence.
What to Know About Security Before Making a phpinfo Page
Creating a phpinfo page is easy (we’ll show you in just a bit), but it can expose sensitive details about your server if not handled carefully. Before you make one, it is important to understand the risks and best practices.
Key Things to Know
- Public exposure is risky. A publicly accessible phpinfo page shows your PHP version, extensions, server paths, and other configuration details. This information could be exploited by attackers.
- Limit access. Only developers or trusted team members should view the phpinfo page. Avoid placing it where visitors or search engines can reach it.
- Temporary use. Use the phpinfo page only when you need it. Leaving it on a live server indefinitely increases risk.
Best Practices
- Delete after use. Remove the phpinfo file once you have gathered the information you need.
- Restrict access. Protect the page with a password or limit access to specific IP addresses.
- Use staging environments. On platforms like Cloudways, create the phpinfo page in a staging environment rather than on your live site.
- Monitor usage. If the page must exist temporarily on a server, keep an eye on access logs to ensure only authorized users are viewing it.
Now that we’ve covered the basics, let’s get into the step-by-step for creating your own phpinfo page. Whether you are running a site locally, on shared hosting, or a managed platform, the process is going to be nearly the same.
How to Create a phpinfo Page
In this section, we’ll create a simple phpinfo page together. By the end, you’ll be able to open it in your browser, see all your PHP configuration details, and know how to handle the file safely.
Step 1: Open a Text Editor
Start by opening a plain text editor. This can be Notepad on Windows, TextEdit on Mac (make sure it’s in plain text mode), or a code editor like VS Code or Sublime Text.
I’ll use the simple Notepad. The editor is where you will write the PHP code that generates your phpinfo page.
Step 2: Write the PHP Code
In your editor, type the following single line of code:
<?php phpinfo(); ?>
Yep! That’s all the code there is.
This is all you need. When executed, PHP will create a page listing every detail about your server configuration. This includes the PHP version, installed extensions, memory limits, file paths, and other settings.
Step 3: Save the File
Save the file as phpinfo.php. It is important that the extension is .php, otherwise your server will not run the code and it may display as plain text. Choose a simple and clear filename so you can easily identify it later.

Step 4: Upload the File to Your Server
Next, you need to place the file where your server can run it. Typically, this will be in the web root folder of your site:
- On a local server, this might be a folder like htdocs or www.
- On shared hosting, you can use the file manager or an FTP client to upload it to the root of your site.
Since I’m using Cloudways, I can upload it to my application folder via the Cloudways Application File Manager or by connecting via SFTP/SSH. I’ll go with the latter option and use FileZilla.
I want to keep things separate from my live site so I’ll create a new application on my existing Cloudways server. This gives me a clean environment to test without affecting anything else.


Now that my new app is ready, I’ll pull up FileZilla and connect to my server using my Master Credentials.


Once connected, I just have to locate the new app I created on my server. To do that, I need to look up its DB Name which I can find from the access details section of my app in the Cloudways platform.


Next I’ll access the public_html folder and drag and drop the phpinfo.php file into this folder.

At this point, the file is on the server and ready to be opened in your browser.
Step 5: Open the File in a Browser
Now, open your browser and go to the URL where the file is located. For example, if your domain is example.com and you saved the file in the root folder, you would visit:
https://example.com/phpinfo.php
I’ll visit this URL in my case: https://phpstack-1070279-6079323.cloudwaysapps.com/phpinfo.php
You should now see a full page showing all the details of your PHP setup. This is your phpinfo page, and it’s a handy way to confirm exactly how your server is configured.

Run PHP 8.4 (Or Any Legacy Version) Effortlessly
✓ Switch PHP versions in 1 click
✓ Auto-test compatibility with your codebase
✓ Free downgrade protection for legacy apps
✓ Security patches for older PHP versions
How to Remove or Secure the phpinfo File
Once you’ve checked your PHP configuration, it’s important to either remove or secure the phpinfo file. Leaving it accessible on a live server can expose sensitive information that could be used by attackers.
Removing the File
The simplest and safest option is to delete the file. On Cloudways, I can do this through the Application File Manager or via your SFTP client. Just navigate to the public_html folder (like we did earlier) and remove phpinfo.php.

Securing the File
If you need to keep the phpinfo page temporarily for testing, make sure it is not publicly accessible. You can:
- Password protect the file using .htaccess rules if your server supports it.
- Restrict access by IP address, so only trusted devices can open the page.
- Use a staging environment, like a separate app on Cloudways, instead of the live site.
Taking these precautions ensures that your phpinfo page can provide the information you need without putting your server at risk.
Conclusion
A phpinfo page makes it easy to see exactly how your PHP setup is configured. It’s useful for troubleshooting issues, checking installed extensions, or confirming server settings after changes.
In this blog, we covered what the phpinfo() function is and why it’s useful, the key security considerations before creating a phpinfo page, a step-by-step guide to creating your own phpinfo page, and how to remove or secure it after use.
If you have any confusion or run into issues, leave a comment below and we’ll help you out.
Frequently Asked Questions
Q1: What does phpinfo(); do?
phpinfo(); shows a complete overview of your PHP environment. It lists the PHP version, server information, loaded extensions, configuration settings, environment variables, memory limits, and paths to important files like php.ini. Essentially, it gives you a full snapshot of how PHP is running on your server.
Q2: How to call phpinfo()?
You call phpinfo(); by adding it inside a PHP file. For example:
<?php
phpinfo();
?>
When this file is executed on your server, it generates a page displaying all PHP configuration details.
Q3: How do I view phpinfo()?
To view phpinfo(), open your browser and navigate to the PHP file you created. For example:
https://yourdomain.com/phpinfo.php
The page will display all the PHP information. Remember to secure or delete the file after use to avoid exposing sensitive server data.
Q4: How to create phpinfo in PHP?
To create a phpinfo page:
- Open a plain text editor (like Notepad, TextEdit in plain text mode, or VS Code).
- Type
<?php phpinfo(); ?>and save the file asphpinfo.php. - Upload the file to your server’s web root folder, such as
public_html. - Open the file in your browser to see your server’s PHP setup.
Optionally, use a staging environment or restrict access if you need the file temporarily for testing.
Abdul Rehman
Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.