Resolving an unable to fork PHP warning in Windows

来源:互联网 发布:淘宝手机怎么开店认证 编辑:程序博客网 时间:2024/05/16 05:34
 

Symptoms

In Windows, when trying to execute a system callfrom a PHP script, you receive a warning like "Warning: system()[function.system]: Unable to fork". A related warning message is"Warning: shell_exec() [function.shell-exec]: Unable to execute"

Sample Code

<?php
// print output of shell command executed with backtick operator
print htmlentities(`dir`);
?>

Cause

The most likely cause is insufficient permissions to execute system calls in the web server environment.

Fix

You need to give the Internet Guest Account (a.k.a. IUSR_MachineName or simply IUSR) read and execute permission to the command shell program, cmd.exe. Typically, permission to this file is explicitly denied as a security measure.

  1. Open Windows Explorer and browse to the c:/windows/system32 or c:/winnt/system32 directory.
  2. Right-click on cmd.exe, and select Properties....
  3. Click the Security tab. See image below.
  4.  
  5. If Internet Guest Account is not already listed, then click Add, then Advanced..., then Find Now.
  6. Scroll down to and select IUSR_MachineName, where MachineName is the name of your computer.
  7. Click OK twice to return to the Security tab.
  8. Select Internet Guest Account and then click the box under Allow for Read & Execute.
  9. Click OK.
原创粉丝点击