0

Good Morning,

Newbie Alert!! :)

I created a virtual host on my FreeBSD server and have the domain name pointing to the server. I uploaded site files to /home/servername/www/virtualhostname. I see there are alos files in /usr/local/apache2/htdocs. These are the generic "Welcome to your Server" HTML file and image files.

Do I need to remove the files from /usr/local/apache2/htdocs in order for the server to render the files in /home/servername/www/virtualhostname?

Thanks, Sid

EDIT:
/usr/local/apache2/conf/httpd.conf contains the following:

DocumentRoot "/usr/local/apache2/htdocs"

As such, is it advisable to change the DocumentRoot to the directory of my virtual host? Or, should I just place my site files in the above DocumentRoot and let it ride?

1
  • Thanks for the extra information i have updated my answer with what is the best approch in my personal opnion.
    – Prix
    Aug 22, 2010 at 17:56

1 Answer 1

0

First thing, make sure your domain is pointing to the correct ip of the server you are using, a simple ping domain.com would do it but you can aswell use tracert domain.com or traceroute depending from where you are checking it.

After that, locate the file httpd.conf and vhosts.conf those are your webserver configuration files.

Check if vhosts.conf is empty or not, if it is not empty look for DocumentRoot entries and post the content for us by updating your question, if it is empty go to httpd.conf and look for <virtualhost entries, if there inst any, it means your webserver is using the server DocumentRoot directory.

Usually the server DocumentRoot directory is /var/www/htdocs but it may change from installation to installation and from OS to OS.

To verify which is the one you have, inside your httpd.conf look for the entry DocumentRoot that is not inside any virtualhost and what is ahead of it is the path to your main root directory.


its better if you make your own VirtualHost for the domain in question, if you have a vhosts.conf file add the bellow cotent to it replacing what is need to your own domain, if you dont have a vhosts.conf add at the end of your httpd.conf file:

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName domain.com
        ServerAlias www.domain.com
        DocumentRoot /home/servername/www/virtualhostname/
        ServerAdmin [email protected]

        ErrorLog /home/servername/logs/domain.com_error_log
        CustomLog /home/servername/logs/domain.com_access_log combined
</VirtualHost>

Make sure you have created the directory /home/servername/logs to hold your log files or that you have it pointed to somewhere you prefer.


Apache webserver works the follow way:

  • If you have no virtualhosts configured it will lead to the server DocumentRoot by either the ip or the ServerName defined.

  • If you do have virtualhosts then you will only hit the server DocumentRoot when you make use of your Server's ServerName (which is the domain defined in the ServerName that is outside and before your virtualhosts in your httpd.conf) otherwise it will lead you to your first virtualhost in your config file.

  • Let's say your first domain is blabla.com and it is using the virtual host *:80, it means ANY IPS that are binded to your webserver will lead to that virtualhost if the user has not defined any domain to access, an example would be the user accessing your ip instead of the domain.

  • If you are always using the domain name to access your domain then it does not matter aslong as you have your virtualhost well configured you will hit the given place you wanted and the files you wanted.
2
  • Thanks for the info. I do have a VirtualHost entry at the end of my httpd.conf file. It's document root is /home/servername/domainname So, the main httpd.conf DocumentRoot is going to /usr/local/apache2/htodcs and the VirtualHost DocumentRoot is going to /home/servername/domainname. If I remove the files from /usr/local/apache2/htdocs, will the contains of the Virtual Host DocumentRoot be served up instead?
    – SidC
    Aug 22, 2010 at 18:06
  • @SidC i have updated the answer with how it works in regards to how it will hit your virtualhost or your server's document root or your domain.
    – Prix
    Aug 22, 2010 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .