1

I am having a problem with virtual host, all of them go to one site and I dont know why.

This is a typical vhost config for one of many domains:

<VirtualHost *:80>

### SERVER ###
##############
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin [email protected]
DocumentRoot /mnt/volume1/domain

### DIRECTORY ###
#################
<Directory /mnt/volume1/domain/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

### LOGS ###
############
LogLevel info
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/domain.access.log combined

</VirtualHost>

Apache Version is 2.4.6 -- Ubuntu 13.10

1 Answer 1

1

You have to create a virtual host for all the sites

<VirtualHost *:80>
  ServerName domain1.com
  ServerAlias www.domain1.com
  ServerAdmin [email protected]
  DocumentRoot /mnt/volume1/domain1

  ## Rest of the settings here for domain1
</VirtualHost>

<VirtualHost *:80>
  ServerName domain2.com
  ServerAlias www.domain2.com
  ServerAdmin [email protected]
  DocumentRoot /mnt/volume1/domain2

  ##rest of the settings here for domain2
</VirtualHost>

restart apache and you should have the domains pointing to the right directory...

You might have to to use the sudo a2ensite domain1 command to enable the sites in

/etc/apache2/sites-available

that way you can set up seperate files for all your virtual hosts ... easier to manage... :)

apache2 allows you to make seperate sites... so check the

/etc/apache2/sites-available/000-default

if you don't have the sites enabled everything by defaults gets pointed to that 000-default virtual host

you have to make sure there is a link in

/etc/apache2/sites-enabled

folder to the config files in

/etc/apache2/sites-available

folder... :)

Cheers...

3
  • All the sites have their own configs and are enabled. Still all goes to one domain.
    – Jon Furry
    Dec 25, 2013 at 2:19
  • I got it. I forgot to reload the config files with /etc/init.d/apache2 reload. After doing that then restarting apache2 with /etc/init.d/apache2 restart, it works.
    – Jon Furry
    Dec 25, 2013 at 2:25
  • cool glad you got it running ... :)
    – Drmjo
    Dec 26, 2013 at 18:10

You must log in to answer this question.

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