Search code examples
apachecgiserver-sidewav

How can I play a wav sound on the server side using cgi?


How can I run a command from a (bash) CGI script to play a wav sound on the server side?


Solution

  • You can execute your command line audio player as described by nak, but this may not work due to the permissions of the user running Apache. By default Apache is run as www-data:www-data (or apache:apache or www:www on some distros). As a quick fix/test you can set Apache to run as a user that has permissions to access the audio device on the machine by modifying your /etc/apache2/apache2.conf (or /etc/httpd/httpd.conf") file to have:

     User USER_THAT_CAN_PLAY_AUDIO
     Group USER_THAT_CAN_PLAY_AUDIO 
    

    Warning: this is not secure and is not intended to be a permanent solution!