1

I have two sites and they are both located in the /var/www/ directory.

one is at...

/var/www/doamin1.com/public_html

the other is at...

/var/www/doamin2.com/public_html

directories are chown to the www-data:www-data user and group.

I have set up the conf files and they are

doamin1.com.conf

and

doamin2.com.conf

and they look like this...

<VirtualHost *:80>

        <Directory /var/www/domain1.com/public_html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ServerName wildcard.domain1.com
        ServerAlias *.domain1.com
        ServerAdmin [email protected]

        DocumentRoot /var/www/domain1.com/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

#vim: syntax=apache ts=4 sw=4 sts=4 sr noet

<VirtualHost *:80>

        <Directory /var/www/domain2.com/public_html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ServerName wildcard.domain2.com
        ServerAlias *.domain2.com
        ServerAdmin [email protected]

        DocumentRoot /var/www/domain2.com/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

#vim: syntax=apache ts=4 sw=4 sts=4 sr noet

added the domains to the host file /etc/hosts

a2dissite 000-default.conf

a2ensite domain1.com.conf
a2ensite domain2.com.conf

service apache2 reload

service apache2 restart

and both domains still direct to the same domain, I even reboot the server and removed the wildcard setup...

ServerName domain1.com
ServerAlias domain1.com

ServerName domain2.com
ServerAlias domain2.com

and they don't direct correctly. Both domains are owned and DNS is pointing to the correct location. Everything I do still results in them both redirecting to the same directory.

I have links to my config files in the sites-enabled and conf files for each of my sites, still doesn't work. I am lost.

What am I missing here?

4
  • I have exactly the same problem!
    – iiro
    Nov 5, 2015 at 9:53
  • Did you try the answer bellow? if not let me know what your setup is exactly.
    – phlipinmi
    Nov 5, 2015 at 18:48
  • 1
    yes and it worked. I first tought it isn't working becouse i had mispelled few letters! I spent atleast one working day handling this before i found this post. Thanks!
    – iiro
    Nov 7, 2015 at 11:32
  • No problem glad I could help!
    – phlipinmi
    Nov 8, 2015 at 22:11

1 Answer 1

2

What I found was that for each virtual host configuration...

/etc/apache2/sites-availiable/doamin1.com.conf

and

/etc/apache2/sites-availiable/doamin2.com.conf

<VirtualHost *:80>

*//configriation*

</VirtualHost>

I changed /etc/apache2/sites-availiable/doamin1.com.conf to look like this

<VirtualHost domain1.com:80>

*//configriation*

</VirtualHost>

and /etc/apache2/sites-availiable/doamin2.com.conf to look like this...

<VirtualHost domain2.com:80>

*//configriation*

</VirtualHost>

I think that this is because both files were looking for the *:80 directive in the opening line of the block. This then caused the server to revert to the first conf file and used the "DocumentRoot" in that virtual host block.

0

You must log in to answer this question.

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