Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mp3 jukebox
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help!
View previous topic :: View next topic  
Author Message
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Mon Jun 13, 2005 9:51 am    Post subject: mp3 jukebox Reply with quote

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
Back to top
View user's profile Send private message
youlikeicecream
LXF regular


Joined: Fri Jun 03, 2005 12:40 pm
Posts: 721
Location: Oxford

PostPosted: Mon Jun 13, 2005 12:49 pm    Post subject: RE: mp3 jukebox Reply with quote

permissions ? the user you try to run the app / play the audio as will probably need permission to the files
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Mon Jun 13, 2005 1:23 pm    Post subject: RE: mp3 jukebox Reply with quote

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)
Back to top
View user's profile Send private message
bigbee



Joined: Thu Jun 09, 2005 3:46 pm
Posts: 55
Location: Westerlo, Belgium

PostPosted: Mon Jun 13, 2005 2:26 pm    Post subject: RE: mp3 jukebox Reply with quote

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.
_________________
Back to top
View user's profile Send private message Visit poster's website
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Tue Jun 14, 2005 12:44 am    Post subject: RE: mp3 jukebox Reply with quote

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
Back to top
View user's profile Send private message
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Tue Jun 14, 2005 10:42 am    Post subject: Re: mp3 jukebox Reply with quote

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
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Tue Jun 14, 2005 10:46 am    Post subject: RE: Re: mp3 jukebox Reply with quote

Code:
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)
Back to top
View user's profile Send private message
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Tue Jun 14, 2005 11:13 am    Post subject: RE:Jukebox Reply with quote

It's already set at that.

But I did change the line in mp3jb to point to file in my home directory.
Quote:

my $conf_dir = "/home/ben/music/test.mp3";


The log now writes:
Quote:

File exists at /usr/bin/mp3jb line 25.


But still no sound Sad

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

Quote:
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?
Back to top
View user's profile Send private message
skecs



Joined: Fri Apr 22, 2005 10:22 am
Posts: 76
Location: Bathurst, NSW Australia

PostPosted: Tue Jun 14, 2005 11:22 am    Post subject: RE:Jukebox Reply with quote

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!
Back to top
View user's profile Send private message
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Tue Jun 14, 2005 1:06 pm    Post subject: RE: Jukebox Reply with quote

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.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Tue Jun 14, 2005 4:31 pm    Post subject: RE: Jukebox Reply with quote

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)
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Jun 15, 2005 3:35 am    Post subject: RE: Jukebox Reply with quote

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.
Back to top
aussben



Joined: Mon Jun 13, 2005 9:39 am
Posts: 6

PostPosted: Wed Jun 15, 2005 8:55 am    Post subject: RE: Jukebox Reply with quote

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
Back to top
View user's profile Send private message
bigbee



Joined: Thu Jun 09, 2005 3:46 pm
Posts: 55
Location: Westerlo, Belgium

PostPosted: Wed Jun 15, 2005 11:39 am    Post subject: RE: Jukebox Reply with quote

congratz! Smile
_________________
Back to top
View user's profile Send private message Visit poster's website
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8457
Location: Warrington, UK

PostPosted: Wed Jun 15, 2005 12:23 pm    Post subject: RE: Jukebox Reply with quote

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)
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Help! All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast