4

How do I best figure out if and where Apache is installed on a windows machine?

I'm writing a script that uses the installed apache, but sets up it's own config & server-root, and I don't want to hardcode it nor have the user explicitly set it (unless necessary).

I tried to search the registry, but couldn't find anything useful.

Update for those posting default paths

On my machine, it was in C:/Program Files/Apache Software Foundation/Apache2.2. And if I had Vista 64-bit, it'd probably be under 'Program Files (x86)'. And if the computer doesn't have an English OS, it's even worse.

Workaround

Guess I have to check %PROGRAMFILES% for Apache 2.0 or 2.2's default path, then fall back to a prompt. It's be nice to read the registry and find out exactly where it is.

Final note

Apache was not installed for 'Everyone', but only the current user. That makes it a bit more difficult to find as there are no services nor registry keys/folders to point there.

Macke
  • 22,774
  • 6
  • 76
  • 108

5 Answers5

1

You can get the path to the service exe in the services.msc too.

(my apache for some reason is installed in AppData. don't know why if it's because I've installed using chocolatey)

enter image description here

then

enter image description here

then

enter image description here

PS: sorry, about the portuguese in the UI. but I guess it still pretty understandable.

--

EDIT

programaticaly you may run this line in cmd and check if it helps: wmic service get PathName | findstr apache

mukade
  • 562
  • 1
  • 6
  • 9
  • 1
    How to find that programmatically though? I needed it from python or from an installer IIRC. – Macke Dec 25 '18 at 15:20
  • run this line in cmd and check if it helps: `wmic service get PathName | findstr apache` – mukade Dec 25 '18 at 21:23
1

Not really an answer, but if I were you, I'd only use the default path (%PROGRAMFILES%\Apache Group\Apache2\bin\Apache.exe) or a couple of relatively safe default paths, and prompt if the executable was not found.

Otherwise it might pick up a completely unexpected installation. I hate programs that are "too smart".

Jaka Jančar
  • 10,536
  • 9
  • 51
  • 74
  • Seems like this is the only way. The registry key in the doc does not contain the default ServerRoot as stated. :-| – Macke Apr 09 '09 at 13:48
  • Not sufficient, see my own answer here to the proper solution. Finding something _and_ prompting anyway is a good idea though, if it comes to that. (This installer was pretty limited in scope anyway...) – Macke Oct 23 '11 at 11:23
1

I apparently installed Apache only for me (current user), not for all users on my machine, hence no registry key.

If installed for all users, the registry key is here:

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache\2.2.xx\ServerRoot
Macke
  • 22,774
  • 6
  • 76
  • 108
1

Search for httpd.exe in the registry under HKLM\Services\CurrentControlSet.

0

On Windows it is installed in c:/Program Files/Apache Group/Apache2/bin/Apache.exe

Rest of the directories (conf, log, doc-root, etc) are under c:/Program Files/Apache Group/Apache2

David Rabinowitz
  • 28,033
  • 14
  • 88
  • 124
  • 1
    yeah, if you follow the Qick Installation route when installing Apache, this is where it'd go by default. but I think this isn't a solution to marc's problem. – Peter Perháč Apr 08 '09 at 14:36
  • Precisely, It doesn't end up there always, only by default. In my case, I had forgotten to install it for All Users. – Macke Feb 26 '11 at 23:18