0

I have been searching the internet for an hour now, and I was hoping for a quick hint here so that I could solve my problem a wee bit faster.

My virtual server is so far only accessible through an IP address, no DNS entry yet, and so far none needed either.

The problem I have is with Apache2, the virtual hosts are puzzling me.

What I need is:

Access to my project (based on Symfony2) from the outside with the IP address

Access to my project from localhost

What I have got:

Access from the outside results in rendering the websites in /var/www/vhosts/htdocs/default, while from the inside results in rendering the websites in /var/www. Why the difference?

What is a recommended configuration for my use case?

2 Answers 2

2

My guess is that the first parameter after the <VirtualHost part of your Apache config is 127.0.0.1. This will mean that when you request a website on the loopback interface you hit one vhost and on any other interface you get a different vhost.

The output of apache2ctl -S will probably tell you what is going on.

6
  • In /etc/apache2/sites-available I have a default VirtualHost configuration which is using /var/www as DocumentRoot; thus I don't understand how it can get to /var/www/vhosts
    – Carl
    Nov 29, 2011 at 15:41
  • 1
    Post your httpd.conf and any virtual host config files (redact any sensitive information, shouldn't be much to begin with). We'll have a much better chance of helping you then.
    – Chris S
    Nov 29, 2011 at 15:52
  • My httpd.conf is empty, the only file I have is the default file in /etc/apache2/sites-available. The content: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> # content related to CGI </VirtualHost> Thanks :)!
    – Carl
    Nov 29, 2011 at 23:14
  • It's probably best to post that in your question where you can format it properly. Anyway, it seems my first guess was wrong. The next thing I would suggest is recursively grepping for the two different document roots you identified in your config directory: grep -r DocumentRoot /etc/apache2/ or ` grep -r "/var/www/vhosts/htdocs/default" /etc/apache2/`.
    – Ladadadada
    Nov 29, 2011 at 23:27
  • 1
    "I" solved it, there was an interference caused by the pre-installed Plesk application. Now it is working fine. I interpreted the output of apache2ctl -S in a wrong way at first, but then I took a look at it again and noticed what was going on. Thanks for your help!
    – Carl
    Nov 30, 2011 at 14:30
0

if you cant use hostname for virtual host, maybe you should use different port than 80 ? ex

 <VirtualHost 10.1.1.10:8080>
    DocumentRoot /var/www
    ...
    </VirtualHost>

You must log in to answer this question.

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