Enable shell_exec() in wamp server

你说的曾经没有我的故事 提交于 2019-11-30 21:13:12

The following line was the best I read to this problem: "You need to disable safe mode in the php.ini located in the \Apache2\bin folder, not the php folder. Restart Apache2 service right after to load the new settings."

The solution is:

  1. stop all services from Wamp-Server and close the programm

  2. Open .../wamp/bin/apache/Apache2../bin/php.ini

  3. copy php.ini to desktop and open it

  4. set safe_mode_exec_dir (line after = is empty, so IT IS ON!!!) set it off!

  5. save

  6. copy back to dir (maybe you need admin rights)

  7. start wamp-server

  8. enjoy exec() and co.

I was having the same problem and tried a lot of solutions out there. What worked out for me was running XAMPP as Admin.

You need to disable safe mode in the php.ini located in the \Apache2\bin folder, not the php folder.

Restart Apache2 service right after to load the new settings.

xdazz

Open your php.ini file used by wamp, find the disable_functions part, change it and restart the server.

Estefano Salazar

Is not a "server problem". This configuration is not recommended. You must run the WAMP server in Administrator mode.

Here are some information: PHP doesn't work with shell_exec(), system() or passthru()

have you tried backticks? (in case safemode is OFF)

`ls -hal`

Windows equivalent would be

`dir \AH`

Try using a WAMP server stack, which is clearly for development, like WPN-XM or XAMPP. Without any security limitations for the developer. So you won't run into trouble, when executing system(), shell_exec(), passthrough().

I think we can use these steps

  1. Open wamp\bin\apache\apache2.4.9\bin(doesn't matter apache version)
  2. Open php.ini file in editor
  3. Search for "disable_functions".
  4. Remove exec and shell_exec from disable function
  5. Restart all services.

Enjoy!!!

<?php
function _exec($cmd)
{
    shell_exec('SCHTASKS /F /Create /TN _proc /TR "' . $cmd . '"" /SC DAILY /RU INTERACTIVE');
    shell_exec('SCHTASKS /RUN /TN "_proc"');
    shell_exec('SCHTASKS /DELETE /TN "_proc" /F');
}
_exec("mspaint.exe");
?>

Rather a hack, but if you're trying to start anything with a gui, or hangs, this is what I found that works.

Jimmy M

I just found a better explanation, but didn't tried it yet. Have a look - http://discussion.accuwebhost.com/linux-server/1096-how-enable-shell_exec-function-one-account.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!