How To Create phpinfo Pages?
PHP is very popular programming language used by a lot of programmers and web devleopers. 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 provides information like PATH, User, Operating System, Modules etc.
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.
Ubuntu, Debian, Mint, Kali:
$ sudo apt install php
Fedora, CentOSi RHEL:
$ sudo yum install php
Create phpinfo.php Page
We will start by creating a phpinfo web page. Actually it is very easy to create one. We just use following PHP code to list phpinfo.
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 the path
$ 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 On Command Line
If we need to run
phpinfo in a more secure and local way we can use command line option which will put the output of the phpinfo page into terminal.
$ php7.2 phpinfo.php
$ php phpinfo.php
Run phpinfo On From Commmand Line with Php Web Server
We can also create a temporary web server which 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 web server.
$ php7.2 -S 0.0.0.0:8080 phpinfo.php
WordPress phpinfo Plugin
If we are running a CMS (Content Management System) like WordPress we have options which is more practical then creating a web page and serve it. WordPress provides the PHPINFO plugin from the following link.