The Apache Haus Forum

Advanced search  

News:

Welcome to Apache Haus Distribution Forum

Pages: [1]   Go Down

Author Topic: [PHP] Get apache pid and path  (Read 9751 times)

mario

  • Administrator
  • Member Elite
  • *****
  • Offline Offline
  • Posts: 579
[PHP] Get apache pid and path
« on: May 04, 2009, 02:51:58 PM »

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


Code: [Select]
<?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
Code: [Select]
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>
Logged
Pages: [1]   Go Up
 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13