I try to use php exec() run command as sudo, but not working. I also edited my sudoers(visudo) file with the following lines.

sudo visudo:

apache  ALL=(All) NOPASSWD:

Here is php code:

exec("sudo ping -c 1",$output);

How can I fix this problem?

New contributor
YunHong is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • This question is badly off-topic on this site. You can post it & will get an answer on Stack Overflow if you 1) post code 2) say what the code should do 3) say what is going wrong. Good luck :-) – Mawg Aug 14 at 10:16

Your Answer

YunHong is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.