Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Edit: I think part of the problem is I needed to use port 8080, but I'm still getting the "unable to connect" message. Is there anything I need to configure in /etc to make that accessible?

--

It seems likely that this is an obvious question, but I'm having trouble tracking down any useful information. Normally when accessing files in a particular directory on a server, I'm able to create a virtual host, assign a domain, root directory location, etc -- however am in a situation where I have server space and need to access files with only a hostname. Is this possible?

For example, let's say the hostname is 123hostname.com, and the file I want access to is in /home/sub-directory/filename.php. How do I get at it via a browser?

I've tried:
http://123hostname.com/home/sub-directory/filename.php

...and some other variations on that theme (that I can't post because new users are restricted to one link in messages). But generally stuck. Any help -- even if it's just to let me know that this isn't possible without some additional configuration -- would be great. Thank you!

share|improve this question
    
Are you saying that, in your current situation, you have a server without any kind of web service (ie, Apache) available? I think we need some more details about this server that you're having troubles with. –  Paul Kroon Jun 12 '10 at 1:58

2 Answers 2

up vote 0 down vote accepted

Usually web servers are configured to only allow access to user files in a specific directory, traditionally the public_html directory. The url format would be http://example.com/~user/dir/file.html which would translate to /home/user/public_html/dir/file.html

This is for security reasons. Imagine if anyone could access your .ssh_keys directory from the web, anyone could break into that account.

For that reason, there isn't any way that you do what you want directly.

On the other hand, there is nothing wrong with accessing a server by hostname. A virtual host is just another name for that same server, which usually has different content served out. There is nothing you can do with a virtual host which you can't also do with the correct hostname.

share|improve this answer
    
Thanks gorilla, that definitely helps. I've dug into it a little more, and I think part of the problem is I needed to use port 8080, but I'm still getting the "unable to connect" message. Do you know if there's anything I need to configure in /etc to make that accessible? Updated the question above. –  jonathanatx Jun 12 '10 at 0:52

Providing read-access to every file on a system via http (at least the files that the Apache User can read) is generally not considered ideal. If you really want to, however, it can be done.

There are two potentially useful answers to your question. The first is to set up a default VirtualHost (or to not configure any VirtualHost at all). The second is to use mod_userdir.

If there are existing VirtualHost entries on the web server that bind to the primary IP of the web server (or at least the IP that the server's hostname resolves to), then the first listed VirtualHost entry will be used as a default. It's contents will be displayed when Apache is accessed either by IP address, or by a hostname which resolves to the IP and has no other matching entry.

If there is no requirement for VirtualHost entries on the primary IP, then Apache will serve content from the directory assigned to the DocumentRoot directive.

If you want to serve content from several different user accounts without configuring any VirtualHosts or Aliases, then you will likely want to use mod_userdir. The Apache documentation provides a better description of mod_userdir than I have to offer.

http://httpd.apache.org/docs/1.3/mod/mod_userdir.html

share|improve this answer
    
Regarding your "port 8080" bit. You may have to explain why you need to use a port other than the default. –  Sam Rodgers Jun 12 '10 at 1:10
    
Thanks Sam - this was helpful as well. This is an environment where I have fairly limited access to Apache (similar to a shared hosting environment), and it sounds like too limited to take care of the problem myself (which is exactly what I was trying to figure out). I appreciate the insight! –  jonathanatx Jun 12 '10 at 1:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.