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

by Vivek Gite on April 6, 2006 · 10 comments

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

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 10 comments… read them below or add one }

1 AW March 21, 2008

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 vivek March 21, 2008

Yes, php is not installed or enabled.

Reply

3 ATM January 4, 2010

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

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

Reply

5 vamsi June 23, 2010

excellent way of presentation

Reply

6 westyfesh September 25, 2010

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 Vivek Gite September 25, 2010

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

Reply

8 zhelp June 28, 2011

Thank you :)

Reply

9 Grateful Fred August 5, 2011

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

Reply

10 Amy October 30, 2011

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

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 3 + 13 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: