Login or Sign Up
Add a Fix
Amixer doesn't work when executed in PHP
The ProblemI am building a web interface for my audio on Ubuntu Server 12.04. I want to mute the mic from my browser, however, the command exec("amixer sset 'Mic',0 mute"); worked only intermittently.
Summary: The problem is that the user www-data had in ufficient permissions to run amixer. To fix this you need to first determine the user that php uses:
Then I gave that user passwordless privelages to run one script under my account (jake):
And insert this line, filling in your info:
www-data ALL=(your username here - in my case jake) NOPASSWD: /home/jake/scripts/mute.sh
Then I put the command that I wanted to run (amixer sset 'Mic',0 mute) in the mute.sh bash file. And I executed the script in PHP as shown below:
exec("sudo -u jake /home/jake/Scripts/./mute.sh");
Now amixer mutes every time!
There are no resources.
CommentsAdd a Comment
There are no comments.