Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been trying to get this work for hours now. I am trying to set up virtual hosts with Apache on my VPS.

I have the following virtual host file in my sites-available folder :

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/domain.ie
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/domain.ie>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

I have issued the a2ensite domain.ie command on the virtual host.

I have also issued the restart and reload commands. I have also stopped the Apache server and started it, using both commands, to see if Apache is in fact restarting, and it is. I have also restarted the VPS box completely.

The document root folder does exist, but the apache service still serves up the default apache page. I would prefer not to disable the default virtual host.

Am I missing a step here? Should I be adding something to my hosts file in /etc/hosts? domain.ie has been added there by apache : 127.0.0.1 localhost.localdomain localhost domain.ie

Any help on this would be greatly appreciated.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

You need a ServerName directive in the <VirtualHost> block, so that Apache knows when to serve content from that virtual host.

share|improve this answer
    
Thank you womble, this solved my issue. –  Dave O Dwyer Aug 5 '12 at 1:03

I also had the problem show up when I defined DocumentRoot before setting ServerName in my <VirtualHost ...> directive.

share|improve this answer

Add

NameVirtualHost *:80

to your apache config also, your file looks have no

</VirtualHost>

more docs here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

share|improve this answer
    
The OP only provided the vhost definition; it's a fair bet the NameVirtualHost is elsewhere in the config. –  womble Aug 5 '12 at 0:48

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.