3

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.

Dave O Dwyer
  • 161
  • 1
  • 6

3 Answers3

5

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

womble
  • 96,255
  • 29
  • 175
  • 230
1

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

zb'
  • 117
  • 7
  • The OP only provided the vhost definition; it's a fair bet the `NameVirtualHost` is elsewhere in the config. – womble Aug 05 '12 at 00:48
1

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

hko
  • 11
  • 1