Create a phpinfo.php on Linux

How to Create a phpinfo.php on Linux

Today we will learn How to Create a phpinfo.php on Linux. After complete installation of a LAMP server or LEMP server on a Linux system. It is common to create a phpinfo.php page to verify that PHP is functional and has settings.

To create a new file, you can use Nano, Vim, or any other command line or GUI text editor. You can give any name.

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

<?php phpinfo(); ?>

This may vary based on the Linux distribution you are running. The web hosting application you have installed (such as Apache, NGINX, etc.), and how you have configured the system.

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

Once placed there you can view the PHP file using a web browser. Use the fully qualified domain name of your server or 127.0.0.1 to view the page.

This page generates a lot of data. If you are only interested in specific information to get a small output, you can pass different options to this method.

INFO GENERAL, for example, provides some basic details, including configuration lines, 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 contains all the necessary details about your server’s configuration. Using PHP’s interactive shell, you can get the same information as if you access your server directly via the command line.

Conclusion

Creating a phpinfo page is often helpful for solving complex PHP problems. This page will show data about the current configuration of the PHP installation on the server.

Scroll to Top