I'm trying to have a php script play an audio file when run

shell_exec('aplay /home/andrew/www/audio/meeting-bell/medium-bell.wav')

It works when I run it from the command line, but not when running it from PHP.

I'm running Apache under the same user name (andrew), but when I run it from the command line (via SSH) it plays with no complaints.

However, when I trigger the script from PHP, I get the following error:

ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4241:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4720:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM default
aplay: main:682: audio open error: No such file or directory

I looked around and people recommended that I add the user (andrew) to the 'sound' group.

When I try to do this, I get a message saying that:

useradd: group 'sound' does not exist

I'm not really sure what to do from here... Anyone have any tips for setting up an audio group... Am I headed in the right direction?

  • What are the permissions of the devices in /dev/snd/? What is the output of id executed from PHP?
    – CL.
    Jun 15, 2014 at 18:32
  • 1
    Changing the permissions on /dev/snd/ made everything work! Submit as an answer and I will approve it. :) Jun 16, 2014 at 2:44
  • I don't know what the wrong/correct permissions are; you'll have to write it yourself.
    – CL.
    Jun 16, 2014 at 7:41
  • I voted to close because the root cause appears to be a simple error in the group name. Nov 4, 2021 at 15:48

1 Answer 1


Check what groups there are using:

getent group

To add a user to a group, use:

sudo usermod -a -G username groupname
  • This is more a comment than an answer.
    – RalfFriedl
    Jun 18, 2019 at 5:15
  • Yes, yours is more of a comment than an answer, but that's what the comments section is for. The above helped me, that's why I answered. OP was trying to add a user to a group called 'sound,' which did not exist. At that point, OP was stuck. Knowing how to check for all the groups certainly pointed me in the right direction, i.e. there is a group called 'audio' that I needed to add the user to, and it got my aplay working. That information is more useful here than not at all. I know this won't help OP 5 years later, but it certainly helped me and may be of use to others. Jun 19, 2019 at 7:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.