Monday, May 18, 2009

Is PHP supported on my Web Server?

Recently, I had to install a PHP-based web application on my Apache web server.

My first question was: "Is PHP enabled on the web server?"

You can always ask the systems guy. But if you happen to be the systems guy, and you don't quite remember if you have installed PHP, here is how to find out.

  1. Create a new file with a php suffix (say myphp.php)
  2. Copy and paste the following code into the php file.
    (I cannot get to display PHP code; use the code in the April 29, 2009 comment)
  3. Save the file and upload it to a location on your web server that is accessible to the World Wide Web.
    For expedience, upload it to the Apache document root directory which is /var/www on my Debian Etch server.
  4. Open your web browser to the URL for that PHP file (http://localhost/myphp.php).

If your web server supports PHP, the browser will return with a page full of information about the PHP version and configuration. In addition, it will display information about your web server and your system in general.

On the contrary, if all you see is a blank page, then you know PHP is not supported.

Note that you must delete the myphp.php file from your web server after you obtain the necessary info. You don't want people to run the PHP script, and obtain sensitive information about your system.

StumbleUpon Toolbar


Anonymous said...

You wanted to say the following code(without the #s):
#< ?
#p h p i n f o ()
#? >

Anonymous said...

And without the spaces!

Anonymous said...

or the easier way, run php -v from the command line and you will know in less than a second.