Test PHP Installation With a Phpinfo page under UNIX / Linux Apache Web Server

by on April 6, 2006 · 15 comments· LAST UPDATED September 25, 2010

in

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:

<?php
 phpinfo();
?>

Open your web browser and type the url: http://example.com/test.php.
Sample outputs:

Fig.01: phpinfo script output

Fig.01: phpinfo script output

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 15 comments… read them below or add one }

1 AW March 21, 2008 at 2:11 pm

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?

Reply

2 nixCraft March 21, 2008 at 5:30 pm

Yes, php is not installed or enabled.

Reply

3 ATM January 4, 2010 at 10:12 pm

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

<?php
phpinfo();
?>

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

Reply

4 Mayur May 21, 2010 at 1:00 am

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

Reply

5 vamsi June 23, 2010 at 9:05 am

excellent way of presentation

Reply

6 westyfesh September 25, 2010 at 8:35 am

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

Reply

7 nixCraft September 25, 2010 at 9:06 am

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

Reply

8 zhelp June 28, 2011 at 3:20 am

Thank you :)

Reply

9 Grateful Fred August 5, 2011 at 3:58 am

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

Reply

10 Abbas September 15, 2011 at 6:30 am

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

Reply

11 Amy October 30, 2011 at 12:35 am

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 example.com domain. My installation seems to be fine. Please help. I am new to php.

Reply

12 richard nuxon March 12, 2012 at 7:41 pm

@westyfesh
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

Reply

13 joseph January 16, 2013 at 10:23 pm

Thankyou for your contribution, Regards!

Reply

14 marc January 22, 2014 at 7:18 pm

I just get a plain white screen running that command?

Reply

15 Nix Craft January 22, 2014 at 10:26 pm

Check web server log file.

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: