Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if PHP is installed on Apache or IIS Server?

Tags:

php

iis

apache

Is there a way to check if PHP is installed on an Apache or IIS server within the PHP environment itself?

If so, how?

like image 239
Oliver Spryn Avatar asked Feb 28 '12 16:02

Oliver Spryn


People also ask

How do I know if PHP is installed on Apache?

php in the Web server document root (installdir/apache2/htdocs/ for Apache or installdir/nginx/html for NGINX). Make sure the Web server is running, open a browser and type http://localhost/phptest.php. You should then see a screen showing detailed information about the PHP version you are using and installed modules.

How do you check that PHP is installed?

1. Type the following command, replacing [location] with the path to your PHP installation. 2. Typing php -v now shows the PHP version installed on your Windows system.

Does IIS support PHP?

The fastest and easiest way to install PHP on Internet Information Services (IIS) is by using the Microsoft® Web Platform Installer (Web PI). Web PI completely automates setting up IIS, FastCGI, and the latest version of PHP from the php.net Web site.


4 Answers

create a file (say info.php) with the following content on an accessible path and try to browse it:

<?php
phpinfo();
?>

@Alfabravo is correct: don't forget to delete the file from the server after using it!

like image 67
Nir Alfasi Avatar answered Oct 19 '22 18:10

Nir Alfasi


Create a PHP script called php.php with the content:

<?php
phpinfo();
?>

and run it from your browser. Or from command line, run:

php -v
like image 38
j08691 Avatar answered Oct 19 '22 19:10

j08691


I don't know with what PHP version it became available, but try this:

if( strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) 
  echo 'Have Apache';
else
  echo 'Have some other server';
like image 7
untill Avatar answered Oct 19 '22 19:10

untill


The virtually most definitive answer possible (there are other similar possibilities) is:

function on_iis() {
    $sSoftware = strtolower( $_SERVER["SERVER_SOFTWARE"] );
    if ( strpos($sSoftware, "microsoft-iis") !== false )
        return true;
    else
        return false;
}

Now, just use on_iis() whenever you want to know.

like image 6
Gabriel Ryan Nahmias Avatar answered Oct 19 '22 18:10

Gabriel Ryan Nahmias