How To Create phpinfo Pages? – POFTUT

How To Create phpinfo Pages?

PHP is a very popular programming language used by a lot of programmers and web developers. During PHP application development we may need to get detailed information about the platform the PHP web server runs. This type of information is provided by phpinfo function. The phpinfo() function provides information like PATH, User, Operating System, Modules, etc.

Install PHP

We will use php command PHP Framework in this tutorial. So we need to install it properly before starting. We can install PHP like below.

Install PHP For Ubuntu, Debian, Mint, Kali:

In order to create and run the phpinfo.php page, we will install the PHP which is provided the package named php. For deb-based distributions like Ubuntu, Debian, Mint, and Kali the following command can be used to install the latest version of the PHP.

$ sudo apt install php

Install PHP For Fedora, CentOS and RHEL:

The PHP package also provided for the rpm based distributions like Fedora, CentOS and RHEL with the following yum command. The package is also the same name which is php.

$ sudo yum install php

Create phpinfo.php Page

As the phpinfo is provided with the phpinfo() function we should create a PHP page first. Then we will create the PHP tags like <?php and ?> . The last step is putting the phpinfo() function inside the PHP tags.




Run phpinfo On Apache Web Server

As we know PHP is a dynamic server-side language. We need to run PHP code on the server with PHP framework and Web Server Application which is Apache in this case. Put the code described above into the path /var/www/html . We will copy the created phpinfo.php PHP script or web page into the /var/www/html directory.

$ cp phpinfo.php /var/www/html

and run following command to start Apache Web Server. But we need to be sure that PHP modules are installed properly.

$ sudo systemctl start apache2


$ sudo systemctl start httpd

Run phpinfo Page On Command Line

If we need to run phpinfo in a more secure and local way, we can use the command-line option which will put the output of the phpinfo page into the terminal. In this case, we do not need to install the Apache, Nginx or related web server as the php command builtin internal server feature will be used. Keep in mind that this is not a complete or reliable server. Use this for only testing purposes. We can provide

$ php7.2 phpinfo.php


$ php phpinfo.php
Run phpinfo On Command Line
Run phpinfo On Command Line

Run phpinfo On From Command-Line with Php Web Server

We can also create a temporary web server that will serve the phpinfo web page. We will use again the php command. We will also provide the IP address and port number we want to run the webserver. In the following example, we will run the phpinfo page on the public interface and port number 8080.

$ php7.2 -S phpinfo.php
Run phpinfo On From Commmand Line with Php Web Server
Run phpinfo On From Commmand Line with Php Web Server
Run phpinfo On From Commmand Line with Php Web Server
Run phpinfo On From Commmand Line with Php Web Server

We can see from the web page that following information is provided with the phpinfo page.

  • System name
  • PHP build date
  • Server API
  • Virtual Directory Support
  • Configuration File (php.ini) Path
  • Loaded Configuration File
  • Additional .ini files parsed
  • PHP Extension
  • Zend Extension
  • Zen Extension Build
  • PHP Extension Build
LEARN MORE  Things To Do With Computer When Bored

WordPress phpinfo Plugin

If we are running a CMS (Content Management System) like WordPress we have options that are more practical than creating a web page and serve it. WordPress provides the PHPINFO plugin from the following link.

Leave a Comment