aspose file tools*
The moose likes Linux / UNIX and the fly likes Browsable Directory under /var/www in Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Browsable Directory under /var/www in Linux" Watch "Browsable Directory under /var/www in Linux" New topic
Author

Browsable Directory under /var/www in Linux

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Are there any additional steps needed to make Linux recognize a certain directory as browsable underneath /var/www/? Is there a conf file that needs to be set up? I've got a plain html page in a directory called /var/www/test and it isn't coming up. Any help would be greatly appreciated.

Rob
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Hi Rob,

your problem sounds more like a webserver problem than a Linux problem.

What exactly do you mean by "browsable"? Browsable via web browser? There's no real concept of browsing local file systems. A directory browser like konqueror makes this possible for you.

If it's a problem with a web directory instead then it depends very much on the web server or serlvet container you're using. It's a configuration option in almost every web server which directories should be browsable. And for your HTML page it could be a problem of the file system rights or perhaps your document root for you web directories could be located in a different directory than /var/www. But this, too, is a configuration problem of the web server.

Perhaps you could describe a little bit more precisely what you're trying to do!

Marco
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Just a plain HTML page. I'm actually trying to figure out why it isn't working through someone trying to set it up remotely. I "guess" they are having no problem browsing (yes through a web browser) a page located in the var/www/html directory on the web server being used. Putting a page in /var/www/test and it doesn't work (can't find the page). The page doesn't have stylesheets, javascript, etc..,, just basic HTML. When I say they are browsing it they are also browsing it from another computer running Windows, not the one acting as the web server. Thanks for the reply.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8708
    
    6

And the web server is?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Ok, I see. This is definitely not a problem with Linux but with your web server. It would be the same problem if you'd run the same web server on windows.

For most web servers (like Apache for example) you have to allow browsing of web directories. That means you have to configure the web server to allow browsing for specified directories which instructs the web server to produce a directory listing if someone tries browsing an directory URL (with a simple slash at the end).

The problem that the web server doesn't find your HTML page is most likely because with your installation the document root isn't /var/www but /var/www/html. Therefore you would have to put your test directory under the document root. The full path would be /var/www/html/test/. The document root of a web server configuration is the most upper directory the web server can "see" (ok, it's possible to include external directories but that's another story).

Unfortunately these are just assumptions as the exact problem is hard to tell without knowing the web server and its configuration or exact error messages from its log. I'd suggest to inspect the log file of your web server. This could give you valuable hints what's wrong here

Marco
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Apache v2 and Redhat Enterprise v5.1. I thought the configuration for the root was /var/www. Do you know what the config file is then?
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 805
Hi guys. Never mind. It's the /etc/httpd/conf/httpd.conf file. It's on another server here where it's working but the contents of the httpd.conf file were removed it looks like. I'm not sure what effect that has on what is accessible and what is not but that looks like the reason why it's working there. I saw that there was a backup of the file and after looking in there saw where the /html directory was initially set as the root. Thanks for the responses.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

On most Linux systems the config files may be under /etc/apache2. The main config file is usually httpd.conf or apache2.conf or the like. The configuration can be split into (many) different directories and files - depending on the Linux distribution and Apache installation.

Unfortunately I have less experiences with Red Hat so I can't tell you exact details but I think there should be enough documentation with the distribution or on the web pages of Apache and Red Hat to figure out the exact config file locations.

Anyway you can search or grep the config files for a parameter called "DocumentRoot" just to be sure that you're not simply putting the web files in the wrong location

Marco
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

I haven't said it in a while, so I'll say it now:

[b]A web server is not a file server.


The problem is, a lot of people think otherwise, since URLs and filesystem paths look so much alike AND because for a lot of web servers, the default action when asked for a URL is to break the URL down into a directory path. But they're not one and the same.

For Apache, you set a document base directory for the server - these days it's commonly /var/www. Viewing files stored under that document base generally requires that you have the index option turned on (at least if you want to be able to see the directory indexes).

What's especially nasty about apache is that unless a whole multitude of constraints are met, the document won't be served and you won't know why.

Among these are:

o The apache server doesn't have read rights to the file or its path
o You don't have authorization rights set in the httpd.conf file or one of its delegates.
o You've got selinux turned on and the selinux requirements aren't being met.

There's probably at least 3 more reasons for failures, but I can never remember them all.


Customer surveys are for companies who didn't pay proper attention to begin with.
Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

Tim, I hope my tips weren't suggestive of a web server being the same as file server?!?

I know it's of course not the same. I just didn't want to make it too complicated and the problem finally seems to cut down to a problem in the file system. At least the problem with the test directory.

I've administrated lots of production web servers and I have to state once more: my hints to a solution were just based on assumptions. Apache is one of the most complex services with the possibly the most configuration options I know of. So it's obvious that it's not possible to explain it here in detail in a few words. And it's not possible to give an exact solution without seeing all details on this server.

Marco
 
Don't get me started about those stupid light bulbs.
 
subject: Browsable Directory under /var/www in Linux
 
Similar Threads
Having trouble reading a file
Apache Configuration in Linux
mod_jk tries to map every request from apache
Java file.mkdir() does not work even after chmod set to 777
windows connecting to subversion server on linux