2

I'm facing a configuration issue that's really diving me nuts ...

Basically I'm working as a sysadmin for a customer who use a single server to host many different site, to be more specific:

Server is:

PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

Linux **xyz** 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u6 x86_64 GNU/Linux

Server version: Apache/2.2.22 (Debian)
Server built:   Aug 18 2015 09:50:52

Now, on top of this I've configured several different web sites at third level, say for example abc.xyz.it, def.xyz.it, ghi.xyz.it, and so on. Everything is working as expected until last week I've been asked to configure one of the virtual host to answer to different external query on slightly different URL redirecting them on the same DocumentRoot. It seems quite trivial, in fact I've managed to allow qqq.xyz.it (original virtual host), plus qqqk.xyz.it and www.qqqk.xyz.it putting the expected configuration in the original /etc/apache2/sites-available/qqq file; then a2dissite qqq, service apache2 reload, a2ensite qqq, and again service apache2 reload ...

As I said everything was working with no problem.

But after a couple of days the customer asked me to add also www.qqq.xyz.it ...

My first thought was that it's simply trivial, so I edited the qqq file adding a section also for this instance ... well, despite several trials I was completely unable to make it run ... it seems to me there is nothing different from what I've done for the other virtual hosts, but no success at all.

I paste below the actual content of qqq file:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName qqq.xyz.it
DocumentRoot /var/www2/qqq
<Directory /var/www2/qqq>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    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}/dri-error.log

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

CustomLog ${APACHE_LOG_DIR}/dri-access.log combined
</VirtualHost>


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.qqq.xyz.it
DocumentRoot /var/www2/qqq
<Directory /var/www2/qqq>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    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}/dri-error.log

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

CustomLog ${APACHE_LOG_DIR}/dri-access.log combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName qqqk.xyz.it
DocumentRoot /var/www2/qqq
<Directory /var/www2/qqq>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    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}/dri-error.log

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

CustomLog ${APACHE_LOG_DIR}/dri-access.log combined
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName www.qqqk.xyz.it
DocumentRoot /var/www2/qqq
<Directory /var/www2/qqq>
    Options -Indexes FollowSymLinks MultiViews
    AllowOverride All
    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}/dri-error.log

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

CustomLog ${APACHE_LOG_DIR}/dri-access.log combined
</VirtualHost>

Does anyone have a guess? I've tried several changes in the order of the four section into the file, I've tried to use ServerAlias which doesn't work in any place into the file ... I've run out of ideas, maybe it's a simple stupid thing but as far as I've been trying so long maybe I cannot see it ....

P.S.: Just to make it clear, the following image shows what I get as a response:

Response

closed as off-topic by dan Mar 6 '17 at 4:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are specific to one website are discouraged because they are unlikely to help future visitors. Examples include individual website reviews for SEO purposes and general website troubleshooting. See the How to Ask page for help improving this question." – dan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • You are not using VirtualHost and Directory directives. Here is an example of a working configuration. webmasters.stackexchange.com/questions/60461/… You are correct that you can point several VirtualHosts to the same DocumentRoot. – closetnoc Mar 5 '17 at 20:56
  • 1
    Can you not use ServerAlias directive... – ultrajohn Mar 5 '17 at 23:35
  • No, for some reason ServerAlias do not work a2ensite gives no error, but then I cannot reach site .... – Davide O. Pandini Mar 6 '17 at 2:07
  • Also regarding post webmasters.stackexchange.com/questions/60461/…, I haven't any public_html directory, unfortunately it's a wordpress site ... – Davide O. Pandini Mar 6 '17 at 2:31
  • 1
    Have you also added the appropriate DNS CNAME record for the www.qqq.xyz.it host to resolve? The "Server not found" error suggests this is not the case, otherwise if the request reached your server you should at least be getting a default config returned (usually the first host that's defined). (ServerAlias really should be working - repeating entire VirtualHost containers just to match another host variation is not good and wholly unnecessary. The order can be important.) – MrWhite Mar 6 '17 at 9:20