Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am having some problems with Apache2 configuration. I have already tried to look for documentation on the web (Apache's site, Debian's site, here on serverfault, etc), but nothing really helps.

I have tried different configurations, but my current configuration is the following (/etc/apache2/sites-available/default):

<VirtualHost *:80>
    ServerAdmin my@mysite.dev
    ServerName mysite.dev
    ServerAlias mysite.dev
    DocumentRoot /var/www/mysite.dev/httpdocs/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin admin@livesite.com
    ServerName livesite.com
    ServerAlias www.livesite.com
    DocumentRoot /var/www/livesite.com/httpdocs/
    <Directory /var/www/livesite.com/httpdocs/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

mysite.dev it's just an entry in hosts file on my client machine, while livesite.com it's an actual DNS record which would resolve to the same IP as the IP set in hosts file for mysite.dev.

The problem is that when i try to type mysite.dev in my browser, it would automatically go to livesite.com.

I tried to have different /etc/apache2/sites-enabled/ files (/etc/apache2/sites-enabled/mysite.dev , /etc/apache2/sites-enabled/livesite.com ) - and of course with the actual sites-available related files, but achieving the same results. I have tried to have a peak on error.log and access.log but there's nothing I can see.

My httpd.conf contains:

AccessFileName .htaccess

And I have no /etc/apache2/conf.d/virtual.conf file.

Any help would be greatly appreciated - if I did not provide enough info please let me know I will do my best to provide all necessary info.

Thanks

share|improve this question

4 Answers 4

in your host file try setting mysite.dev to 127.0.0.1 instead of the pc's ip and also make sure that mysite.dev is the first virtualhost defined in apache, hope this resolves your issue

share|improve this answer
    
hosts file is on client machine, so 127.0.0.1 would redirect to my local apache - instead of the intended server's. mysite.dev is the first virtualhost declared. –  milo5b Oct 13 '12 at 17:17
    
btw, i also have an entry in the server's hosts file - with value 127.0.0.1 –  milo5b Oct 13 '12 at 17:23

This is just a wild guess, but does the Include statement in httpd.conf look something along the lines of: Include /etc/apache/sites-enabled/*.conf

If that's the case, rename /etc/apache2/sites-enabled/mysite.dev to /etc/apache2/sites-enabled/mysite.dev.conf and see if that helps.

Alternatively, do you have the "NameVirtualHost *:80" statement anywhere? I prefer to stick it in httpd.conf or ports.conf on Debian-based Apache installs.

share|improve this answer
    
I have no include line in httpd.conf - I tried to stick all the code in the httpd.conf (including NamevirtualHost *:80 - which was in ports.conf) but no luck there.. –  milo5b Oct 13 '12 at 17:19

Try to change

<VirtualHost *:80>

to

<VirtualHost mysite.dev:80>

and

<VirtualHost livesite.com:80>

I think two *:80 virtualhosts is an ambiguous configuration for the webserver.

share|improve this answer

Thanks to @law and @tristan625 for the answers.

My problem was that Firefox was doing something silly - when i tried the latest configuration (all in httpd.conf) with chrome it just worked (and also FF worked, once I've restarted it).

Silly problem that has wasted a cpl of hours of my life!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.