Uploaded Site Files not Displaying After Creating Virtual Host on FreeBSD

Posted on

Uploaded Site Files not Displaying After Creating Virtual Host on FreeBSD – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about apache-2.2, freebsd, , , .

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?


/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?

Solution :

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 support@domain.com

        ErrorLog /home/servername/logs/domain.com_error_log
        CustomLog /home/servername/logs/domain.com_access_log combined

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

  • 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.

Leave a Reply

Your email address will not be published. Required fields are marked *