mp3 jukebox

The place to post if you need help or advice

Moderators: ChrisThornett, LXF moderators

mp3 jukebox

Postby aussben » Mon Jun 13, 2005 8:51 am

Hi All

I am trying to setup a mp3 jukebox. I am following the instructions as layed out in the linux format magazine.

I have installed Apache and have it running fine with PHP support.

I have installed the MP3 Daemon and it runs fine. I can play a mp3 file fine as root, which is how the tutorial says to test it.

So I write the PHP script exactly as the toturial describes:

<HTML><head><title>MP3 Jukebox</title></head>
<BODY><pre>
<?
echo ("<H1>Test Jukebox!</H1>");
shell_exec ("/usr/bin/mp3jb play /home/ben/music/test.mp3");
$strOutput=shell_exec("/usr/bin/mp3jb ls");
echo($strOutput);
?>
</pre>
</BODY>
</HTML>

Save it as index.php

Now when I run it through my browser 127.0.0.1/index.php All I get is the html text. The php scrit does not start up the mp3 file, no sound nothing.

I can execute the script from cli with php /var/www/index.php and it works fine. I tried running the browser as root from cli "galeon 127.0.0.1/index.html" still the same no sound.

Now there seems to be a few wholes in this toturial. Is there anyone out there that has manage to get this setup working? Or have any suggestions?

-Ben
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

RE: mp3 jukebox

Postby youlikeicecream » Mon Jun 13, 2005 11:49 am

permissions ? the user you try to run the app / play the audio as will probably need permission to the files
youlikeicecream
LXF regular
 
Posts: 721
Joined: Fri Jun 03, 2005 11:40 am
Location: Oxford

RE: mp3 jukebox

Postby nelz » Mon Jun 13, 2005 12:23 pm

It looks more like Apache is not configured to serve PHP files.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8469
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

RE: mp3 jukebox

Postby bigbee » Mon Jun 13, 2005 1:26 pm

First of all, confirm your phpinstall is working fine:
a simple page
<html>
<head><title>My very own php test page</title></head>
<body><? phpinfo();?></body>
</html>
will hopefully show some nice information...

You can test if your phpsettings allow shellexecuting (safe-mode)
http://www.php.net/manual/en/function.shell-exec.php
http://www.php.net/manual/en/features.safe-mode.php
e.g. bij echoing a simple "ls -l"

Is it possible you have your /home/ben dir not readable for others?
As far as I know (don't shoot me if I'm wrong) the http daemon of apache has its own user (for security purposes), so I can think of a way your mp3 isn't visible for the daemon. This would explain why you can run your phpscript as root, but not through the http protocol.
Image
User avatar
bigbee
 
Posts: 55
Joined: Thu Jun 09, 2005 2:46 pm
Location: Westerlo, Belgium

RE: mp3 jukebox

Postby aussben » Mon Jun 13, 2005 11:44 pm

Thanks for your replies.

I do think it's a php problem cause the html part of the page is viewed fine, but the php script is not executed.

I will test the php tonight when I get home. Also you could be wright about the permissions trying to read my home directory.

Thanks again, I will keep you informed on what I found.

-Ben
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

Re: mp3 jukebox

Postby aussben » Tue Jun 14, 2005 9:42 am

Well I tested the PHP and it worked fine. I get a nice page and the shell_exec executes the ls command.

I still cannot get it to work but what I found was in the tutorial it explains to modify mp3 by "mv /usr/bin/mp3 /usr/bin/mp3jb and edit line:

my $conf_dir = "$ENV{HOME}/.mp3";

to

my $conf_dir = "/tmp/.mp3";

The author explains the reason for this is when called by apache the $ENV{HOME}/.mp3 variable does not appear to be set and the .mp3 directory does not get created properly.

The /tmp directory can be anywhere, now if I change the /tmp to my home directory I can run mp3jb with normal permission. But if I change it back to /tmp/.mp3 I get permission denied cause I don't have permission to access the /tmp directory. Either way it does not work. So it seems there is a problem with apache executing the mp3jb program.

I can execute the script via cli as follows and the music plays.

Desktop:/home/ben# php /var/www/index.php
<HTML><head><title>MP3 Jukebox</title></head>
<BODY><pre>
<H1>Test Jukebox!</H1>> 0 "Live at Aria Montreal (11-06)-"
</pre>
</BODY>
</HTML>

Ok since I have been writing this it just dawned on me to check the apache errors.log file doh!! and I found:
Permission denied at /usr/local/share/perl/5.8.4/MP3/Daemon.pm line 84.

Line 84 in Daemon.pm is:

my $client = IO::Socket::UNIX->new (

mmm the plot thickens...

Well I have had enough for now. Any suggestions would be much appreciated.

-Ben
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

RE: Re: mp3 jukebox

Postby nelz » Tue Jun 14, 2005 9:46 am

Code: Select all
chmod 1777 /tmp

will let all users use the /tmp directory, but not interfere with each other's files.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8469
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

RE:Jukebox

Postby aussben » Tue Jun 14, 2005 10:13 am

It's already set at that.

But I did change the line in mp3jb to point to file in my home directory.
my $conf_dir = "/home/ben/music/test.mp3";


The log now writes:
File exists at /usr/bin/mp3jb line 25.


But still no sound :(

Change is back to:
my $conf_dir = "/home/ben/music/.mp3";

Permission denied at /usr/local/share/perl/5.8.4/MP3/Daemon.pm line 84.


It seems like apache has a permission problem accessing the Daemon how what I check the permission for that?
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

RE:Jukebox

Postby skecs » Tue Jun 14, 2005 10:22 am

ls -al /usr/local/share/perl/5.8.4/MP3/

will save you cd'ing into that directory.

The permissions should be 755 or -rwxr-xr-x for any users other than root to read & execute, also check for the same settings on your MP3s, the Apache user (www, www-run, or similar) needs read & execute access to execute the MP3s. The permission denied could be the actual MP3 trying to be played.
Regards from
Downunder!
.... _
... (0)>
... / /\
.. / / .)
.. V_/_
Linux Powered!
User avatar
skecs
 
Posts: 76
Joined: Fri Apr 22, 2005 9:22 am
Location: Bathurst, NSW Australia

RE: Jukebox

Postby aussben » Tue Jun 14, 2005 12:06 pm

Hello from Bathurst I used to work at Uncle Bens a few years back.

Well I change the permission, I also changed back to the original line in the mp3jb program just to see what happened and I get:

Permission denied at /usr/bin/mp3jb line 31.

Well I am off to bed I have have a gutty of this, is seems to be a some sort of permission problem with apache.
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

RE: Jukebox

Postby nelz » Tue Jun 14, 2005 3:31 pm

Probably because the script is running as the apache user, but trying to write to /home/ben.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8469
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

RE: Jukebox

Postby Guest » Wed Jun 15, 2005 2:35 am

I have been reading and reading, well I would say the permission for the apache user which is "user nobody and group nobody" definately does not have permission to execute files in my home directory plus the program mp3jb.

I think I will spend some time reading about permission with apache.

Thanks everyone for your suggestions.
Guest
 

RE: Jukebox

Postby aussben » Wed Jun 15, 2005 7:55 am

Sucess!! It was permission problem with the apache user trying to access the mp3jb program.

Just as a test I change the user in httpd.conf to myself and change the .mp3 directory in mp3jb and voila.

Just thought I would post it just in case anyone decided to follow the tutorial and has simuliar problems.

-Ben
aussben
 
Posts: 6
Joined: Mon Jun 13, 2005 8:39 am

RE: Jukebox

Postby bigbee » Wed Jun 15, 2005 10:39 am

congratz! :-)
Image
User avatar
bigbee
 
Posts: 55
Joined: Thu Jun 09, 2005 2:46 pm
Location: Westerlo, Belgium

RE: Jukebox

Postby nelz » Wed Jun 15, 2005 11:23 am

You would normally set apache to run as user :group apache:apache and keep the files in a directory owned by that user.
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
User avatar
nelz
Site admin
 
Posts: 8469
Joined: Mon Apr 04, 2005 11:52 am
Location: Warrington, UK

Next

Return to Help!

Who is online

Users browsing this forum: No registered users and 1 guest