Hi,
I am working on a project using an Asus Tinker Board running Debian Stretch as a "web server" (it will only be used on a LAN) to turn on a light and play an audio file when a user clicks an html button in a remote browser window.
I've created a Python script that turns on a GPIO Pin and plays an audio file (using PyGame). This runs perfectly from the command line (locally or via SSH).
I also created a PHP file that will call that Python script via the exec() command. (Plan is to use AJAX to call that PHP file which will call the Python script). This PHP script functions perfectly fine when run from the command line as well.
When I call the PHP script from a web browser, the GPIO turns on, but there is no audio from the Tinker Board's audio jack.
I am 99% sure this has to do with www-data not being able to access the audio system but I have tried everything I have found online thus far to no avail.
(Incidentally when run with SUDO, the audio does NOT work, from command line or php exec()).
I have added www-data to the Audio group.
I have tried changing group permissions for all directories from "/" all the way to the folder containing the scripts and sound files (/var/www/html) making sure all have X attribute and even tried 777 on all.
I have added www-data to the pulse-audio group.
When I check the /var/log/apache2/error.log file, I see no errors when run from command line, but after running from browser, I am seeing
Quote:
"Home directory not accessible: Permission denied."
|
The error is associated with calling either Pulse or Alsa because I receive that error whether I try to run my Python script using the exec() command in PHP or even if I just try to use aplay from PHP (
Code:
exec('aplay /var/www/html/sounds/sound.wav')
).
I've tested by commenting out parts of my python script too and as soon as I initialize pygame.mixer:
Code:
mixer.pre_init(44100, -16, 2, 2048)
mixer.init()
It throws the error (twice - once for each line above).
I've read about changing ownership of the "home directory" (which according to /etc/passwd is /var/www in the case of my www-data user) which I've also tried and that has not helped (unless I am not understanding which directory is being referred to).
I feel like the solution has got to be a "simple one" but I just can't figure it out.
Any help would be greatly appreciated!
Thank you very much in advance!