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:
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 12 comments… read them below or add one }
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?
Yes, php is not installed or enabled.
If you’re not seeing anything, you might want also want to try:
(Note the opening <?php tag.) Best – ATM
Thanks for this, i was using echo outside phpinfo, but i was wrong, i am new to php.
excellent way of presentation
what if firefox prompts me to download the php test file (with just the text string )? does that mean that php is not working?
Yes, something is wrong with your webserver and php config. Check web server access and error log files.
Thank you :)
This was a great help. A lot of info from a line of code!
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.
@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
Thankyou for your contribution, Regards!