[PHP] Get apache pid and path

Started by mario, May 04, 2009, 02:51:58 PM

Previous topic - Next topic

mario

Sometimes it is nice to see which apache runs. On my dev machine I run several apache in different versions for testing.
I made a small command line php script for seeing which apache runs. I named it pid.php



<?php
$wmi 
= new COM('winmgmts://');
$processes $wmi->ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'httpd.exe'");
foreach(
$processes as $process){
    echo 
'cmd line: '$process->CommandLine ' --> pid: '$process->ProcessId "\r\n";
}
//reference http://msdn2.microsoft.com/en-us/library/aa394372.aspx
?>



on the command line php.exe pid.php

I:\server2\php>php pid.php
cmd line: "I:\server2\apache\bin\httpd.exe" -w --> pid: 3184
cmd line: I:\server2\apache\bin\httpd.exe -d I:/server2/apache --> pid: 2236

I:\server2\php>