windows 警告:exec():无法在 PHP 中分叉
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8474989/
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
Warning: exec(): Unable to fork in PHP
提问by Kamran Akhter
I'm using php 5 apache on windows server 2008, I have disabled IIS.
我在 Windows Server 2008 上使用 php 5 apache,我禁用了 IIS。
I m using exec command in my PHP script and it was working fine but today I got an error:
我在我的 PHP 脚本中使用 exec 命令,它运行良好,但今天出现错误:
Warning: exec(): Unable to fork
I gave permissions to cmd.exe
in C:\Windows\System32
folder
but this did not fix the problem.
我授予cmd.exe
了C:\Windows\System32
文件夹中的权限,但这并没有解决问题。
采纳答案by Farooq
In 64-bit windows (e.g server 2008), theres a folder named c:\windows\syswow64, that contains all executables/dll, that are required by a 32 bit app. installed on your 64-bit machine. Make sure your required 32-bit .exe/dll etc is placed in that folder. if you cant find it there you will have to put a 32-bit version of the required .exe/dll there.So this can used by yopur app/process.
在 64 位 Windows(例如 server 2008)中,有一个名为 c:\windows\syswow64 的文件夹,其中包含 32 位应用程序所需的所有可执行文件/dll。安装在您的 64 位机器上。确保您需要的 32 位 .exe/dll 等文件放置在该文件夹中。如果在那里找不到它,则必须将所需的 .exe/dll 的 32 位版本放在那里。因此 yopur 应用程序/进程可以使用它。
Now when your 32-bit application/process executes, windows will automatically redirect your process to execute required app in syswow64 folder.
现在,当您的 32 位应用程序/进程执行时,Windows 将自动重定向您的进程以在 syswow64 文件夹中执行所需的应用程序。
Hopefully that should resolve your compatibility issue.
希望这应该可以解决您的兼容性问题。
回答by Richard EB
Specifically which permissions did you give to who? Probably not to the right user..
具体你给了谁哪些权限?可能不是正确的用户..
Run this php script:
运行这个 php 脚本:
echo 'Script is executed by: ' . get_current_user() . getmygid();
It will tell you which user is running the PHP scripts and therefore which user to grant permissions to cmd.exe
.
它将告诉您哪个用户正在运行 PHP 脚本,以及因此向哪个用户授予权限cmd.exe
。
回答by Li1t
I had this problem myself, but was eventually able to resolve it. The problem was due to how I had accidentally set cmd.exe to "Run as Administrator" by default. I say "accidentally" as I thought I was only setting the compatibility settings of a shortcut on my task bar, but it turned-out it was setting the compatibility of the .exe itself. Anyhow, I disabled this by deleting the registry key here:
我自己也有这个问题,但最终能够解决它。问题是由于我不小心将 cmd.exe 默认设置为“以管理员身份运行”。我说“不小心”是因为我以为我只是在任务栏上设置快捷方式的兼容性设置,但事实证明它正在设置 .exe 本身的兼容性。无论如何,我通过在此处删除注册表项来禁用此功能:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
After doing this, everything started working again.
这样做之后,一切又开始工作了。