I want to run multiple domains on my server (only two at the moment). I already changed both nameservers to point to my server.
In the apache2.conf file I enabled "included sites-enabled".
My ports.conf file looks as follows
NameVirtualHost *:80
Listen 80
Listen 443
<VirtualHost xx.xx.xx.xx:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
ServerAdmin [email protected]
ServerName firstDomain.com
DocumentRoot /var/www/
ErrorLog /var/log/error.log
CustomLog /var/log/access.log combined
</VirtualHost>
This is the setting for my main page.
My httpd.conf file looks like this
ServerName firstDomain.com
<VirtualHost xx.xx.xx.xx:80>
ServerAdmin [email protected]
ServerName firstDomain.com
DocumentRoot /var/www/
ErrorLog /var/log/error.log
CustomLog /var/log/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName secondDomain.com
ServerAlias *.secondDomain.com
DocumentRoot /home/user/www/secondDomain.com/htdocs
</VirtualHost>
Options -Indexes All FollowSymLinks MultiViews
Last but not least my "secondDomain" file in "sites-avaiable"
<VirtualHost secondDomain.com>
ServerAdmin [email protected]
ServerName secondDomain.com
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/user/www/secondDomain/htdocs/
# CGI Directory
ScriptAlias /cgi-bin/ /home/user/www/seoncDomain/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /home/user/www/secondDomain/logs/error.log
CustomLog /home/user/www/secondDomain/logs/access.log combined
</VirtualHost>
I also get an error message, everytime I restart the apache server, saying that VirtualHosts xx.xx.xx.xx:80 overlaps with VirtualHosts xx.xx.xx.xx:80.
When I call my secondDomain.com only the firstDomain.com pops up. It seems like the mapping is wrong.
apachectl -t output:
[warn] VirtualHost xx.xx.xx.xx:80 overlaps with VirtualHost xx.xx.xx.xx:80, the first has precedence, perhaps you need a NameVirtualHost directive
Syntax OK
apache2ctl -S output:
[Wed Feb 29 02:05:17 2012] [warn] VirtualHost xx.xx.xx.xx:80 overlaps with VirtualHost xx.xx.xx.xx:80, the first has precedence, perhaps you need a NameVirtualHost directive
VirtualHost configuration:
127.0.0.1:* secondDomain.com (/etc/apache2/sites-enabled/secondDomain.com:1)
xx.xx.xx.xx:443 firstDomain.com (/etc/apache2/ports.conf:12)
xx.xx.xx.xx:80 firstDomain.com (/etc/apache2/httpd.conf:3)
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server secondDomain.com (/etc/apache2/httpd.conf:11)
port 80 namevhost secondDomain.com (/etc/apache2/httpd.conf:11)
port 80 namevhost firstDomain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost firstDomain.com (/etc/apache2/apache2.conf:241)
port 80 namevhost secondDomain.com (/etc/apache2/apache2.conf:249)
Syntax OK
Wordpress is installed through apt-get. I have a symlink in /var/www/ which points to /usr/share/wordpress and activated in /etc/apache2/sites-available and a2ensite.
You have a
NameVirtualHost
directive, but you're not using it. You're specifying the IP address and/or the hostname in your<VirtualHost>
declaration - that's not what you want.Change:
and
To both be simply:
You may try next: