为什么我不能在 IIS 中的网络共享上使用 PHP 脚本中的 shell_exec?
我有一些驻留在网络共享上的 PHP 脚本。为了便于讨论,我们将共享命名为 \\nas\dev
。我在 IIS6 中设置了 \\w2k3dev\
上的网站,通过设置“位于另一台计算机上的共享”,使用 \\nas\dev\
作为其主目录。
我的一些脚本使用 shell_exec
在服务器上执行函数并将结果返回到我的脚本。再次出于争论的目的,假设我只是得到一个目录列表,如下所示:
echo shell_exec('dir');
- 如果我在 IIS 中运行脚本,我不会得到任何结果输出 - 但也没有错误日志。
- 如果我在
\\w2k3dev\
上设置 Apache 并将其配置为使用相同的共享,则脚本运行正常 - 如果我将脚本复制到本地计算机并通过IIS 工作正常。
因此,问题似乎仅出现在 IIS 设置为使用包含 shell_exec
的脚本的网络共享时。我的脚本的所有其他方面都工作得很好。
在 procmon 中进行分析,我可以看到 cmd.exe 的运行方式完全不同,具体取决于它是由 IIS 还是 Apache 运行。我有更多细节,但为了简洁起见,我现在将省略它们,除非有人要求更多细节。
非常感谢您看到这个,我已经无计可施了。
亲切的问候
伊恩
I have some PHP scripts that reside on a network share. For argument's sake, let's call the share \\nas\dev
. I have a Web Site on \\w2k3dev\
set up in IIS6 that uses \\nas\dev\
as its home directory by setting "A share located on another computer".
Some of my scripts use shell_exec
to execute functions on the server and return results to my script. Again for argument's sake let's say I'm just getting a directory listing like so:
echo shell_exec('dir');
- If I run the script in IIS, I get no output - but no error logs either.
- If I set up Apache on
\\w2k3dev\
and configure it to use the same share, the script runs fine - If I copy the script to the local machine and run it through IIS it works fine.
So the problem only seems to be when IIS is set up to use a network share with a script containing shell_exec
. Every other aspect of my scripts work fine.
Profiling in procmon, I can see that cmd.exe operates completely differently depending on whether it's being run by IIS or Apache. I have more details, but for the sake of being concise, I will omit them for now unless someone asks for more details.
Thank you so much for looking at this, I am at my wits end.
Kind regards
Iain
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看 php.net shell_exec 手册上的 IIS 特定注释:
http://www.php.net/manual/en/function.shell-exec.php#84992
http://www.php.net/manual/en/function.shell-exec.php#70817
http://www.php.net/manual/en/function.shell-exec.php #70338
http://www.php.净/手册/en/function.shell-exec.php#43907
You may have a look at those IIS specific comments on php.net shell_exec's manual :
http://www.php.net/manual/en/function.shell-exec.php#84992
http://www.php.net/manual/en/function.shell-exec.php#70817
http://www.php.net/manual/en/function.shell-exec.php#70338
http://www.php.net/manual/en/function.shell-exec.php#43907