0

I have a Apache 2.2.22 + PHP 5.4.9 running on a Ubuntu 12.04

I'm hosting three sites here. For that, i have 2 virtual host pointing to three differents folders.

For example, this is one Vhost for domain1

<VirtualHost *:80>
        ServerName domain1.com
        ServerAlias www.domain1.com
        ServerAdmin support@server.com
    DocumentRoot /mnt/htdocs/domain1.com/public
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /mnt/htdocs/domain1.com/public>
        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}/domain1.com-error.log
    CustomLog ${APACHE_LOG_DIR}/domain1.com-access.log combined
</VirtualHost>

The this here is that the 1% of the hits goes to incorrect folder. the other 99% goes to the correct folder and resolve the correct domain/code.

Example of the error in domain1.com's error log

[Fri Feb 14 15:21:45 2014] [error] [client 10.183.250.134] PHP Fatal error:  Class 'Sitemap\\SitemapServiceProvider' not found in /mnt/htdocs/domain1.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 123, referer: http://www.site2.com/someurl

This service provider doesn't exists because domain2.com is routed to domain1.com's folder.

This error is COMPLETELY RANDOM. If I reload the error page, the site render ok.

I checked all the lines of vhosts, erasing all the non critical to keep it simple but the error continues.

Any thought?

juan
  • 101

1 Answers1

0

I have a theory... I'd experienced an issue like this myself. Here's my thinking:

Do you have a

NameVirtualHost *:80

line in your httpd.conf? Preferably before all your VirtualHost definitions.

If you don't have a line like this, add it. If you have a line that explicitly specifies an IP, like so:

NameVirtualHost 1.2.3.4:80

then either change it to match your VirtualHost definitions, or vice versa. Bottom line is that your NameVirtualHost line needs to match all your VirtualHost lines. Finally, there should be only one NameVirtualHost line for the entire Apache config... i.e. across all the .conf files, you should only see one NameVirtualHost line. You can use something like:

grep -r ^NameVirtualHost /etc/apache2/*

to locate all of them.

If you have more than one NameVirtualHost and/or all your VirtualHost don't match your NameVirtualHost definition, you will get unpredictable/inconsistent behaviour from Apache.

Rouben
  • 1,312
  • 10
  • 15
  • Thanks @rouben. I found NameVirtualHost *:80 on ports.conf All my VirtualHost are and has a ` ServerName domain1.com ServerAlias www.domain1.com ` – juan Feb 17 '14 at 14:02