LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-16-2018, 01:08 AM   #1
roboscan
LQ Newbie
 
Registered: Jul 2018
Posts: 3

Rep: Reputation: Disabled
Can't get audio files to play from Debian server (Tinker Board) output when scripts are executed from browser


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!
 
Old 07-16-2018, 07:33 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,514

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
I think the home directory referred to is the user's home directory. Try 'chown -R $USER:$USER $HOME/' .
 
Old 07-16-2018, 07:51 PM   #3
roboscan
LQ Newbie
 
Registered: Jul 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
I think the home directory referred to is the user's home directory. Try 'chown -R $USER:$USER $HOME/' .
Thank you for your reply. I have already done this and it has not helped. (/etc/passwd says that www-data's home is /var/www. I have /var/www owned by www-data user and www-data group.)

I did just read something that Pulse will only work for one logged in user at a time, so I even tried starting my Tinker Board without logging in but that has not helped either. I am baffled. I have tried every "this worked for me" solution that I have found on the net so far and none of them have worked.

Thanks, again.
 
Old 07-16-2018, 08:40 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,514

Rep: Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000Reputation: 1000
I think the reason it works from the command line but not from a remote browser is the command is executed by different users.
 
Old 07-16-2018, 08:52 PM   #5
roboscan
LQ Newbie
 
Registered: Jul 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
I think the reason it works from the command line but not from a remote browser is the command is executed by different users.
That is the basis of my thinking (users, permissions, etc) but I had hoped modifying the right groups and permissions would fix that. Right now I am working my way down a slightly different path. I notice that when I don't login to the GUI from the Tinker Board itself, and only try SSH, Pulseaudio is not working. When I try to start it from the command line, I'm getting errors about ALSA not being able to find my audio device.

Once I start the desktop (startx) audio functions return (of course my browser issue still exists) but my thinking is that the whole audio system is (maybe) locked down unless run by the user that started it (in my case, user linaro).

I am trying to learn how to start ALSA and Pulseaudio from the command line without loading the GUI and hoping that gets my sound going with "browser control."

Still, if anyone has any ideas or a solution, I am open ears (eyes?)!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Review: Asus Tinker Board S Ė Single-Board Computer LXer Syndicated Linux News 0 03-13-2018 08:51 AM
LXer: Installing Google Play Store on the Asus Tinker Board LXer Syndicated Linux News 0 05-01-2017 12:44 PM
LXer: Tinker Board ships in U.S. at $60 LXer Syndicated Linux News 0 04-19-2017 11:13 PM
Record audio output / audio that is played in a web browser glupa4e Slackware 11 05-21-2013 01:08 AM
USE of ALSA to play audio on custom board manish_jc Linux - Embedded & Single-board computer 1 06-02-2010 07:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration