Is there a way to check if PHP is installed on an Apache or IIS server within the PHP environment itself?
If so, how?
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.
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.
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.
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!
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
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';
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With