Resolving an unable to fork PHP warning in Windows

 

Symptoms

In Windows, when trying to execute a system call from 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.
發佈了33 篇原創文章 · 獲贊 1 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章