I can\'t believe that I haven\'t done this before, but I would like a definitive answer so I\'m all set going forward.
I have an apache config file at /etc/apa
You are telling Apache what IP and port you want to answer it on inside of the ~/
means your default home directory, so if your DocumentRoot
just happens to be the default home
variable then it would work with your existing notation (depending on which user you're running the server as). Then you would declare the server name.
Each domain name you're create a host for needs its own Virtual Host Directive unless you're using aliases.
DocumentRoot /home/sam/public_html
ServerName myproject.localhost
# Other directives here
DocumentRoot /home/sam/public_html/myproject
ServerName myotherproject.localhost
# Other directives here
About Hosts In addition to this, any special name that you create for a host needs to go into a hosts file or in the DNS server as well. This way any web browser that is looking for your server can find it without having to type in the IP. Since you'll likely have multiple hosts on the same IP with your setup if you were to try and access the server with the IP only, you would only get the first host to respond on the IP (usually the top in the vhosts list).