windows 如何找到 Apache 的 httpd.exe 的安装位置?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/730259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find where Apache's httpd.exe is installed?
提问by Macke
How do I best figure out if and where Apache is installed on a windows machine?
我如何最好地确定 Apache 是否安装在 Windows 机器上以及安装在何处?
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).
我正在编写一个使用已安装 apache 的脚本,但设置它自己的配置和服务器根目录,我不想对其进行硬编码,也不想让用户明确设置它(除非必要)。
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.
在我的机器上,它位于 C:/Program Files/Apache Software Foundation/Apache2.2。如果我有 64 位 Vista,它可能位于“程序文件 (x86)”下。如果电脑没有英文操作系统,那就更糟了。
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.
猜猜我必须检查 %PROGRAMFILES% 以获得 Apache 2.0 或 2.2 的默认路径,然后退回到提示。很高兴阅读注册表并找出它的确切位置。
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.
Apache 不是为“所有人”安装的,而是仅为当前用户安装的。由于没有服务或注册表项/文件夹指向那里,这使得查找变得更加困难。
采纳答案by Macke
I apparently installed Apache only for me (current user), not for all users on my machine, hence no registry key.
我显然只为我(当前用户)安装了 Apache,而不是为我机器上的所有用户安装,因此没有注册表项。
If installed for all users, the registry key is here:
如果为所有用户安装,则注册表项在此处:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Apache.2.xx\ServerRoot
回答by Jaka Jan?ar
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.
不是真正的答案,但如果我是你,我只会使用默认路径 (%PROGRAMFILES%\Apache Group\Apache2\bin\Apache.exe) 或几个相对安全的默认路径,并提示可执行文件是否为未找到。
Otherwise it might pick up a completely unexpected installation. I hate programs that are "too smart".
否则,它可能会获得完全意外的安装。我讨厌“太聪明”的程序。
回答by Chris Sherlock
Search for httpd.exe in the registry under HKLM\Services\CurrentControlSet.
在 HKLM\Services\CurrentControlSet 下的注册表中搜索 httpd.exe。
回答by mukade
You can get the path to the service exe in the services.msc too.
您也可以在 services.msc 中获取服务 exe 的路径。
(my apache for some reason is installed in AppData. don't know why if it's because I've installed using chocolatey)
(我的 apache 出于某种原因安装在 AppData 中。不知道为什么是因为我已经使用巧克力安装了)
then
然后
then
然后
PS: sorry, about the portuguese in the UI. but I guess it still pretty understandable.
PS:抱歉,关于 UI 中的葡萄牙语。但我想这还是很容易理解的。
--
——
EDIT
编辑
programaticaly you may run this line in cmd and check if it helps: wmic service get PathName | findstr apache
以编程方式,您可以在 cmd 中运行此行并检查它是否有帮助: wmic service get PathName | findstr apache
回答by David Rabinowitz
On Windows it is installed in c:/Program Files/Apache Group/Apache2/bin/Apache.exe
在 Windows 上,它安装在 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
其余目录(conf、log、doc-root 等)位于 c:/Program Files/Apache Group/Apache2 下