Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use Debian 7 and have installed a virtual host with address sub.domain.com following this tutorial: http://www.debian-administration.org/articles/412

I have enabled it, rebooted the PC but still the subdomain opens /var/www

Here is the file contents of the file named "sub.domain.com", located at /etc/apache2/sites-available/ :

<VirtualHost *>
    ServerName sub.domain.com
    DocumentRoot /usr/share/destfolder
    ServerAdmin info@domain.com
    ErrorLog /var/log/apache2/sub.domain.com-error_log
    CustomLog /var/log/apache2/sub.domain.com-access_log common
</VirtualHost>

By the way when I reload apache's configuration, I get: NameVirtualHost *:80 has no VirtualHosts

Any suggestions?

share|improve this question
add comment

1 Answer

Linking just the tutorial isn't enough information, the better is if you post your configuration file. The thing you end up in /var/www when opening your virtualhost address can have more causes.

Apache configuration file is built the way that without context, the directives are applied globally. Otherwise they apply only within the context. The virtualhosts are done the way the default or * virtualhost is set as default. If there is none such, the first virtualhost encountered while parsing the config is taken as default.

Now, finally, to the possible answer:

1) In your virtualhost you have not set the DocumentRoot directive and the (presumably default) global DocumentRoot is pointing to the /var/www.

2) Your virtualhost is not working in the way you expect. This sometimes happens when you make a mistake in naming. With LogLevel debug enable the debug logging and watch what happens and which virtual host is called when you open the desired address. The log files on Debian are located in (not 100% sure) /var/log/apache2/.

Post your config files and debug messages, you greatly increase the chance of useful suggestions.

Update: Well it seems you turned on name-based virtual hosting. Basically your config looks reasonable. In the <VirtualHost ...> clause, you should specify the destination port like <VirtualHost *:443> and so.

The directives DocumentRoot and ServerName are here, it is ok. Probably your virtual host doesn't get invoked when you request the page.

This can be because the Apache doesn't know, what IP the sub.domain.com points to. Do you have sub.domian.com in DNS or, at least, in hosts file?

More on name-based virtual hosts: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

share|improve this answer
    
Here is the file contents of the file named "sub.domain.com", located at /etc/apache2/sites-available: <VirtualHost *> ServerName sub.domain.com DocumentRoot /usr/share/destfolder ServerAdmin info@domain.com ErrorLog /var/log/apache2/sub.domain.com-error_log CustomLog /var/log/apache2/sub.domain.com-access_log common </VirtualHost> –  barakuda28 Sep 23 '13 at 12:25
    
update to answer –  Fiisch Sep 24 '13 at 18:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.