How do I test php installation with a phpinfo() page under UNIX / Linux Apache / nginx / lighttpd web server?

PHP has a special function called phpinfo(). It displays a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License etc.

Create following test.php script in your /var/www/html directory (or your httpdoc directory) or upload the same using ftp / sftp / scp client:


Open your web browser and type the url:
Sample outputs:

Fig.01: phpinfo script output

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 15 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
15 comments… add one
  • AW Mar 21, 2008 @ 14:11

    If phpinfo just shows the code written out as plain text, exactly as it is in my PHP file, does that mean PHP isn’t enabled?

  • 🐧 nixCraft Mar 21, 2008 @ 17:30

    Yes, php is not installed or enabled.

  • ATM Jan 4, 2010 @ 22:12

    If you’re not seeing anything, you might want also want to try:


    (Note the opening <?php tag.) Best – ATM

  • Mayur May 21, 2010 @ 1:00

    Thanks for this, i was using echo outside phpinfo, but i was wrong, i am new to php.

  • vamsi Jun 23, 2010 @ 9:05

    excellent way of presentation

  • westyfesh Sep 25, 2010 @ 8:35

    what if firefox prompts me to download the php test file (with just the text string )? does that mean that php is not working?

    • 🐧 nixCraft Sep 25, 2010 @ 9:06

      Yes, something is wrong with your webserver and php config. Check web server access and error log files.

  • zhelp Jun 28, 2011 @ 3:20

    Thank you :)

  • Grateful Fred Aug 5, 2011 @ 3:58

    This was a great help. A lot of info from a line of code!

  • Abbas Sep 15, 2011 @ 6:30

    i have developed a website using php. So in order to make it run i installed php,apache,mysql(LAMP) server. I copied the folder into root (/var/www/) folder. when i tried to run the website on my local server. I got a distorted view of the web page. The whole structure of the website is ruined. i think that is because the other folders in my website folder are not accessible. one thing more i am getting a cross on sub folders in my website folder. Help me out with this…please. thanks

  • Amy Oct 30, 2011 @ 0:35

    I can’t get the page to run on my mac. It gives me the “safari cannot open the page message” or takes me to domain. My installation seems to be fine. Please help. I am new to php.

  • richard nuxon Mar 12, 2012 @ 19:41

    i was having the same problem running debain. i started and stopped apache then it was working.
    as root in terminal type:
    apachectl stop
    hit enter then type:
    apachectl start

    hope this helps others too because this was the first page in google for : test.php downloading

  • joseph Jan 16, 2013 @ 22:23

    Thankyou for your contribution, Regards!

  • marc Jan 22, 2014 @ 19:18

    I just get a plain white screen running that command?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum