Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what makes domain names point a specific folder?

i'm working on a server that i inherited from someone, and i'm not a big expert on dns issues. the server hosts more than one domains, and they are all under a folder called /vhosts/. i can't seem to understand how domains are pointing to their respective folder there. i checked httpd.config and there is no directive like this:

<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

i also checked the domain admin and they are all pointing to the server ip. so what am i missing?

like image 604
Moshe Shaham Avatar asked Oct 25 '11 13:10

Moshe Shaham


2 Answers

DocumentRoot is the directive which tells the folder name for a specific hosted domain. For each domain which is hosted on the server, there will be one <VirtualHost> node in the httpd.conf file. So for example, example1.com and example2.com are hosted on this server and their requests are served from /vhosts/www/example1 and /vhosts/www/example2 respectively.

<VirtualHost *>
DocumentRoot /vhosts/www/example1
ServerName www.example1.com
# Other directives here
</VirtualHost>

<VirtualHost *>
DocumentRoot /vhosts/www/example2
ServerName www.example2.org
# Other directives here
</VirtualHost>

Sometimes these settings are defined in other config files. Other config files are included in httpd.conf during startup. If you are unable to find the file that has it then I would suggest that you run

grep -ri "VirtualHost" /.

like image 113
Aziz Shaikh Avatar answered Oct 09 '22 00:10

Aziz Shaikh


The system could be configured for mass virtual hosting:

  • http://httpd.apache.org/docs/2.0/vhosts/mass.html

Alternately, the configurations for the virtual hosts could be declared in included files brought in through an Include statement. Check the httpd.config for Include statements to other vhosts ...

if all else fails, go to the root of the configuration directory and run the following:

 sudo grep -Ri www.domain.tld . 

Should give you a hint where to look ...

like image 4
sdolgy Avatar answered Oct 08 '22 23:10

sdolgy