Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is the root directory where all files are kept (directly from accessing from FTP) always "www" or "public_html" depending on what OS? Or is it possible to rename this folder? And if so, what would be unique about this folder to be able to identify it? i.e. currently I just wrote this;

my $root;
my $ftp = Net::FTP->new($DB_ftpserver, Debug => 0) 
                              or die "Cannot connect to $@";
$ftp->login($DB_ftpuser, $DB_ftppass) or die "Cannot login ", $ftp->message;
my @list = $ftp->dir;

if( scalar @list != 0 ) {
  foreach( @list ){
     if( $_ =~ m/www$/g ){
       $root = "www";
     }elsif( $_ =~ m/public_html$/g ){
       $root = "public_html";

but would not work if it has a different name.

Any help much appreciated.

share|improve this question

migrated from Feb 6 '10 at 23:45

This question came from our site for professional and enthusiast programmers.

My Document Root is always ~/domainname/ for each website. You can configure this how you like. – Rich Bradshaw Feb 7 '10 at 10:25

I'll speak in terms of Apache httpd, since it's a very popular webserver.

The root directory where all files are kept, is generically named DocumentRoot. Please bear in mind that files are kept in DocumentRoot for being served by the web server, not for being shown to you when you log in via FTP. FTP is a totally different protocol that is not related to web sites and in this context it is just a way to allow you, the user, modify/update files on a remote server.

The www / public_html directory that you talk about in your question is probably not DocumentRoot. This is additional functionality of Apache, the mod_userdir module. Please consult its documentation.

As said in the docs, there's an UserDir setting in Apache's configuration file which lets you customize the name of these user directories, from where the web server will serve the sites that belong to different users.

Since there's no restriction on UserDir, you can have anything there, even foobar. You can judge by the content of this directory (HTML files, images) that this can be an user directory that holds a site that's being exposed by Apache. But I'd say that doing this automatically with a script seems unreliable to me. Not to mention that for example you can have a public_html directory that is not an user directory, its name matching the default value for Apache UserDir setting being just a simple coincidence. Ideally, in order to judge about a directory if it's an UserDir, you'll need access to the configuration file of the web server. And normally you don't have it. Web hosting providers can put at most user-specific logs in your home directory.

To summarize: if you need to perform any actions with the user directory, have it come to your script as input data: command-line argument, setting from a config file etc, but do not try to guess it.

share|improve this answer

It all depends on the default configuration of the server. You can configure to another location as well.

On Windows it can be:




or somewhere different.

Belongs on superuser ain't it?

share|improve this answer

The name is configurable in Apache (DocumentRoot - default, according to the 2.2.x documentation, is /usr/local/apache/htdocs). My machine at the office uses neither of the options you mention (offhand, I think it uses htdocs, but its a while since I last fiddled with it).

OTOH, since you mention FTP, perhaps you are thinking of something else; the base directory is still configurable, though.

share|improve this answer

You must log in to answer this question.