LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Making a folder browsable (https://www.linuxquestions.org/questions/linux-server-73/making-a-folder-browsable-552192/)

samnjugu 05-08-2007 03:42 AM

Making a folder browsable
 
I just added a drive to my system now i created a directory in it and am trying to make it browsable by the web server but am having some difficulty doing it.

Do i need to edit httpd.conf or add user apache to the folder. Any help will be greatly appreciated.

fukawi2 05-08-2007 03:54 AM

Define "browsable by the web server..." please :)

samnjugu 05-08-2007 02:51 PM

Ok i want to put some folders with music files and enable the user my webserver apache in this case to be able to have access to the folder so that a web application am running can able to access the music files, the only way its working right now is for me to put the music folders either in webserver base or in the public_html folders but i dont wanna do this since this are on the main hard drive and i would like to have my music files on a separate drive.

fukawi2 05-09-2007 02:29 AM

you can just create a Symbolic Link from the Apache root directory to where your files are...

Code:

ln -s /home/myuser/music /var/www/html/music
Or something like that, assuming your music on the separate hard drive is /home/myuser/music and your web server serves out of /var/www/html... Then you music would be accessible via http://servername/music

You will have to loosen up your file and folder permissions on the destination directory (/home/myuser/music)

The best way is probably to change the group the the group of the web server daemon and allow group Read / Execute permissions:

Code:

chgrp apache /home/myuser/music
chmod g+rx /home/myuser/music

Assuming your web server daemon runs with the group 'apache'

samnjugu 05-11-2007 04:10 AM

thanks fukawi2 i will go try it out

samnjugu 05-11-2007 11:02 PM

Back to the drawing board tried it but it didn't work had my hopes up all day but i will keep looking.

fukawi2 05-12-2007 01:57 AM

I guarantee it works - I do it often.

What error messages are you getting?

samnjugu 05-14-2007 01:18 AM

this is the error log that showed up on logwatch

--------------------- httpd Begin ------------------------


Requests with error response codes
403 Forbidden
/music: 2 Time(s)


i will go and check my logs when i get to the house and add them here thanks fukawi2 coz i know it can work myself i just dont know how yet.

fukawi2 05-14-2007 01:23 AM

Can you post the output of the following commands please?

Code:

ls -lh /home/username/
ls -lh /path/to/http/root/
id <username>
id apache

/path/to/http/root is probably /var/www/html on Fedora :)

samnjugu 05-15-2007 09:32 AM

ls -lh /home2/muthii/music
total 8.0K
drwxrwxr-x 2 muthii muthii 4.0K Dec 26 20:52 kenya mp3

ls -lh /var/www/html
total 228K
-rw-r--r-- 1 root root 17K Nov 25 14:02 animated_favicon1.gif
drwxr-xr-x 5 muthii muthii 4.0K Aug 12 2006 blog
drwxrwxr-x 8 muthii muthii 4.0K Jul 21 2006 calender
-rw-r--r-- 1 muthii muthii 4.3K Jul 19 2006 contact2.php
-rw-r--r-- 1 root root 4.4K Aug 5 2006 contact.php
-rw-r--r-- 1 root root 17K Dec 5 16:39 favico.gif
-rw-r--r-- 1 root root 3.6K Nov 25 14:00 favicon.ico
drwxr-xr-x 10 muthii muthii 4.0K Jul 11 2006 forum
drwxr-xr-x 3 muthii muthii 4.0K May 12 14:19 images
-rwxr--r-- 1 muthii muthii 19K May 12 14:32 index.html
-rwxr-xr-x 1 muthii root 298 Mar 19 13:30 index.html~
-rw-rw-r-- 1 muthii muthii 20K Apr 28 23:21 links.html
drwxrwxr-x 16 muthii muthii 4.0K Oct 12 2006 mail
lrwxrwxrwx 1 root root 19 May 11 17:30 music -> /home2/muthii/music

nb: removed unnecessary listings on second command to other folders.

Hope this helps.

fukawi2 05-15-2007 06:35 PM

You forgot the 2 'id' commands :)

samnjugu 05-16-2007 09:04 AM

there is my id
id muthii
uid=500(muthii) gid=500(muthii) groups=500(muthii),0(root)
id apache
uid=48(apache) gid=48(apache) groups=48(apache)

fukawi2 05-16-2007 10:18 PM

Sounds like just a permissions problem - your apache and muthii user don't overlap at all; ie, to each other, they both fall under the "other" group.

It might even be a problem with the /home2 directory permissions, but probably with /home2/muthii which probably has rwx------ permissions (ie, no access for the group or "other")

3 solutions:
1) Add apache to your user group
2) Change the group ownership on all the file / directories that Apache needs to access and give group at least Read access to files and r-x access to directories
3) Change all the directories that Apache needs to access to have r-- for files and r-x for directories to the "other" group (not recommended from a security point of view.)

systemnotes 05-17-2007 01:32 AM

Quote:

Originally Posted by fukawi2
Sounds like just a permissions problem - your apache and muthii user don't overlap at all; ie, to each other, they both fall under the "other" group.

It might even be a problem with the /home2 directory permissions, but probably with /home2/muthii which probably has rwx------ permissions (ie, no access for the group or "other")

3 solutions:
1) Add apache to your user group
2) Change the group ownership on all the file / directories that Apache needs to access and give group at least Read access to files and r-x access to directories
3) Change all the directories that Apache needs to access to have r-- for files and r-x for directories to the "other" group (not recommended from a security point of view.)

Aside from the permissions recommended, it sounds link an SELinux problem.

http://systemnotesorg.blogspot.com/2...otes-http.html

You can check with
ls -Z /var/www/html
ls -Z /home2/muthii/music

And probably fix it with this:
chcon -R --reference /var/www/html /home2/muthii/music

samnjugu 05-17-2007 03:07 AM

thank you for both replies i will go and try it out


All times are GMT -5. The time now is 09:18 PM.