LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2009, 12:30 AM   #1
Joel Koltner
LQ Newbie
 
Registered: Mar 2009
Posts: 4

Rep: Reputation: 0
How to list the contents of Apache's cgi-bin directory?


Hello,

I'm fond of Apache's "option indexes" feature that, in lieu of finding an index.html file, will just list the contents of the directory instead. However, I can't get this to work in my cgi-bin directory, despite trying a lot of messing around with my default site configuration file and directory permissions. (Note that I *can* execute CGI scripts just fine -- this isn't a problem.)

Here's my configuration file:

Code:
<VirtualHost *:8080>
    ServerAdmin "webmaster@localhost.com"
	
	DocumentRoot /var/www/

	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>

	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride all
		Options +ExecCGI Indexes Multiviews FollowSymLinks
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel info

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>
...and I'm trying to list the directory using the URL: http://atomix:8080/cgi-bin/ . The result is a "403 Forbidden" error.

Any ideas what I might need to fix? (As mentioned, something like http://atomix:8080/cgi-bin/TestScript works just fine...)

I've also found that even without "+ExecCGI" in the options line CGI scripts are still executed ... I suppose this is the default? (I was trying to make /usr/lib/chi-bin's configuration indentical to /var/www's, which does list the directories as I'd like.)

This is running Apache 2.2.9 and Ubuntu 8.10.

Thanks for the help,
---Joel Koltner

Last edited by Joel Koltner; 03-27-2009 at 12:34 AM.
 
Old 03-27-2009, 05:21 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You can use a script to show you the cgi-bin directory contents in a browser window. Something like this will do the job:
Code:
#!/bin/sh

echo "Content-type: text/plain"
echo
ls -l
 
Old 03-27-2009, 05:29 PM   #3
Joel Koltner
LQ Newbie
 
Registered: Mar 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
You can use a script to show you the cgi-bin directory contents in a browser window.
Ha... well, that's clever, thanks -- I'll use it.

I'd still love to know what I'm not doing correctly with Apache itself though!

I appreciate the help,
---Joel
 
Old 03-27-2009, 06:13 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
I'm afraid you cannot list the cgi-bin contents, because this is the way the ScriptAlias directive works. It means that everything in that directory must be executed as script (thus you cannot execute a directory).
You can overcome this by changing ScriptAlias with just Alias and add a "AddHandler cgi-script .cgi .pl" among the other directives inside the Directory definition.
 
Old 03-27-2009, 11:23 PM   #5
Joel Koltner
LQ Newbie
 
Registered: Mar 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
I'm afraid you cannot list the cgi-bin contents, because this is the way the ScriptAlias directive works. It means that everything in that directory must be executed as script (thus you cannot execute a directory).
You can overcome this by changing ScriptAlias with just Alias and add a "AddHandler cgi-script .cgi .pl" among the other directives inside the Directory definition.
Ah, excellent. Thanks for the information!

---Joel
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Tried but in vain to list contents of a directory rs_vijay Programming 3 01-17-2007 03:59 PM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 04:02 AM
cannot list directory contents kpachopoulos Linux - General 2 11-29-2005 05:24 PM
Apache's CGI directory don_wombat Linux - Software 7 03-01-2005 12:14 PM
List the contents of a directory to a file MasterC Linux - General 19 11-26-2002 10:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration