How do I enable directory listing on my server?

pfhorseti

Registered
Hi,

I am trying to set up my own server using Mac OS X.2. My server is working, only problem is that it denies directory listing. So for example when I want my mp3 files listed in /~user/mp3/, it just says directory listing denied and won't let me view them. Is there a way to enable directory listing?

Thank you!
 
You want 'Options Indexes' (no quotes) in your httpd.conf. If you only want directory listing turned on for that particular directory, you can do that in the httpd.conf as well, or the easiest way is to put the above directive into a file in that directory called .htaccess .
 
Thanks for the quick reply.
I decided to go with the easier way.
I tried naming the file .htaccess but the OS wouldn't let me, saying that '.' is reserved for the system. So what should I do? Thanks again!
 
Oh, if you already have the file, then just type:

mv filename .htaccess

where filename is what you already created.
 
Okay, so I got my .htaccess file in my folder. I have that folder in my Sites folder. I access the page but it still says Forbidden. My .htaccess file contains 'Options Indexes'.
 
Also, do I have to put the .htaccess file in every folder inside that folder? Or does the .htaccess file take effect recursively through its sub-directories...I hope?
 
.htaccess files will effect recursively. Okay, so if you have there with 'Options Indexes' without the single quotes, then you might not have that option enabled for your user. :) Go into /etc/httpd/users and look for your username.conf. Where you see 'AllowOverride None', change None to All. Then do an 'apachectl restart' to make it take effect. You will probably have to do these things as root, or precede each command with 'sudo', and in 'sudo apachectl restart'.
 
Ok, I didn't see a myusername.conf file in etc.httpd/users, so I created one with pico, and put 'AllowOverride All', saved and put the file in there.
I did the restart command and it gives me an error:

[ool-435114f9:/etc/httpd/users] hisaokin# sudo apachectl restart
/usr/sbin/apachectl restart: configuration broken, ignoring restart
/usr/sbin/apachectl restart: (run 'apachectl configtest' for details)
[ool-435114f9:/etc/httpd/users] hisaokin# apachectl configtest
Processing config directory: /private/etc/httpd/users
Processing config file: /private/etc/httpd/users/hisaokin.conf
Syntax error on line 1 of /private/etc/httpd/users/hisaokin.conf:
AllowOverride not allowed here

It says it's not allowed.
What now? :confused:
 
Well, I didn't see a file so I created my own... probably shouldn't have.
Here's the file, nothing in it but the line you told me to put in:

UW PICO(tm) 2.5 File: hisaokin.conf // this line is not content
// no space in this line either
AllowOverride All
 
Ah, exactly. Assuming that you are using Sites in your home directory for the web pages, then this is what should be in your hisaokin.conf:

< Directory "/Users/hisaokin/Sites/" >
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
< /Directory >


Take the spaces out from the angled brackets. If I left it as it should be, the web site would parse them out as html or something. I guess turning on Indexes is default for this. So the above should work fine. That's the default. I thought OS X created one of these for every user. On my system it seems to have.
 
Excellent! No prob. Sorry it took so long. This is not the best venue for this kind of help. :)
 
Back
Top