Find the answer to your Linux question:
Results 1 to 5 of 5
Let's say I have an application installed that needs Apache to actually display it on the browser. Before running the application in the browser, the first step is to make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    106

    Smile Directory listing for Apache web server


    Let's say I have an application installed that needs Apache to actually display it on the browser.

    Before running the application in the browser, the first step is to make sure the Apache web server is running (the browser is enabled), and then make sure whether or not the directory listing can be viewed when typing :

    http://hostaddress/index.php

    (In this example, my Directory Index points to index.php)

    What if I do not want a particular directory to be listed in the browser?

    Do I edit the httpd.conf file in the "Directory" section e.g :

    Code:
    <Directory "/path/to/directory">
    '
    '
    '
    '
    '
    </Directory>
    or do I edit the "Directory Index" section?

    or is there any other proper way??

    Thanks in advance,
    ana

  2. #2
    srj
    srj is offline
    Just Joined! srj's Avatar
    Join Date
    Jan 2012
    Location
    Bucharest
    Posts
    86
    Hello,

    In Apache the directory listing is done in 2 ways using 2 directives/modules.

    1. using the DirectoryIndex directive from the mod_dir module:

    Using this option the server will only show the index for the folders with the "DirectoryIndex <file.html>" directive and the file.html file inside. (The files can have any name you want.)

    Ex:
    <Directory "/path/to/directory">
    DirectoryIndex index.php #Apache will search for index.php in /path/to/directory/ and display it's content if found
    </Directory>


    2. using the Options +Indexes from the mod_autoindex module.

    Using this module, Indexes are generated automatically for all the folders inside.
    To disable this for a particular folder use this:

    Ex:
    <Directory "/path/to/directory">
    Options -Indexes # Apache won't generate autoindexes for /path/to/directory/
    </Directory>


    Also be advised that both modules can work together. In this case the server will search for index.php, index.html, index.htm files (files you mentioned in httpd.conf) and if none are found mod_autoindex is started.


    =-=-=-=-=-=-=-=-
    So, first you should choose one of the above methods (or both) and decide how will you restrict listing for the particular folder after.

    I hope this answered your question.

    Cheers,
    Srj
    Last edited by srj; 12-03-2012 at 01:26 PM.

  3. #3
    srj
    srj is offline
    Just Joined! srj's Avatar
    Join Date
    Jan 2012
    Location
    Bucharest
    Posts
    86
    In your example the URL is directly to the index file.

    Be advised that Apache will provide index files only if the URL ends with "/" and the last part is a folder. Ex: http://hostaddress/folder/

    If "/" is not used "mod_dir" directive will send a redirect to the client. The redirect will contain the full path "http://hostaddress/folder/" but if the server is not configured correctly or if mod_dir is not loaded this won't work.

    Remeber to end the URL with "/" to let the server know it's a folder.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    106
    Thanks for the reply!

    But may I know where the mod_dir or mod_autoindex modules are located??

    For my configuration, the line DirectoryIndex index.php was in the file
    httpd-dms.conf (another file). This file is a file to configure paths and other options for the application I was to use in the browser.

    and path for the apache root directory was listed in httpd.conf.

    So are these 2 files where these modules are located?

  6. #5
    srj
    srj is offline
    Just Joined! srj's Avatar
    Join Date
    Jan 2012
    Location
    Bucharest
    Posts
    86
    The modules are located where your Apache server was installed, usually in a subfolder called "modules" and their extensions is ".so".

    If you installed the server using a pre-compiled package most likely all the modules are already included. (both mod_dir and mod_autoindex).

    You must understand that Apache is a modular server and certain features are only available with the help of those extra modules. For example, the "DirectoryIndex" directive you found in your configuration file won't be available without the mod_dir module.

    The modules are either compiled within your httpd executable (all the modules are built-in, but I don't think so) or loaded from your configuration file with the "loadmodule" directive. You can say a module it's a ".dll" file from the world of Windows. (If this analogy helps you)

    Look for the "LoadModule" directive within your httpd.conf to see if they are loaded from there and disable/enable them as you wish. I don't know how to use the application you mentioned but from what it looks like the "httpd-dms.conf" is working with Apache.

    If you really want to start this server up I suggest you read the user guides (Documentation: Apache HTTP Server - The Apache HTTP Server Project) or guides from any other sources (but please make sure you read the correct guides for your version) and reply back if you have other questions.

    Cheers,
    Srj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •