Solved

Vhost configuration

Posted on 2006-07-15
10
766 Views
Last Modified: 2008-03-06
Hi,

I have configured a virtual host on my apache 2 web server, but the are pointing to the same site.
I have created two folders under www, i.e. htdocs & demo.
Under vhost.d i have 2 config files
default_vhost.conf
demo_vhost.conf

Default_vhost.conf have the following enteires
<VirtualHost *:80>
    ServerAdmin webmaster@mywebserver.com
    ServerName www.mywebserve.com
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /srv/www/htdocs
    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/error_log
    CustomLog /var/log/apache2/access_log combined
    # Include /etc/apache2/conf.d/*.conf
    <Directory "/srv/www/htdocs">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

and Demo has the following :
<VirtualHost demo.mywebserver.com:80>
    ServerAdmin webmaster@mywebserver.com
    ServerName demo.mywebserver.com
    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /srv/www/demo
    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/demo.mywebservert.com_error_log
    CustomLog /var/log/apache2/demo.mywebserver.com_access_log combined
    # Include /etc/apache2/conf.d/*.conf
    <Directory "/srv/www/demo">
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Please help me resolve this problem.

Thank You.
0
Comment
Question by:Wrathyimp
10 Comments
 
LVL 24

Expert Comment

by:slyong
ID: 17115648
Hi,

Sorry, what's the problem?
0
 
LVL 7

Expert Comment

by:CraigHarris
ID: 17117860
<VirtualHost *:80>
<VirtualHost demo.mywebserver.com:80>

Are those differences intentional? - do you have appropriate DNS entries for such?
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 17118540
Refer here:

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

The one possibility I see is no NameVirtualHost declaration.  This directive is not optional for name-based virtual hosts.  You need one of these directives for every distinct point of contact.

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName www.mywebserve.com
# ... other stuff
</VirtualHost>

<VirtualHost *:80>
  ServerName demo.mywebserver.com
# ... other stuff
</VirtualHost>

Also keep in mind that the first listed vhost entry for any particular NameVirtualHost becomes the default...if a ServerName/ServerAlias cannot be matched in your vhost containers, the first vhost will be used.
0
 
LVL 1

Author Comment

by:Wrathyimp
ID: 17148079
Sorry to come so late.

But routinet, I tried to change the NameVirtualHost to *:80 on both the vhost.cong files, but to success, only pointing to the www.mywebserver.com, even when i type demo.mywebserver.com, it takes me to www.mywebserver.com
So is there something to do with httpd.conf?

Thank You.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:Wrathyimp
ID: 17148233
In my DNS entries, I have given demo as alias to www, so it should point to the same machine.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 17148520
From your command line:

# httpd -S

This is not the link found /etc/init.d.  The full path on mine is /usr/sbin/httpd.  That command should dump a list of the current vhosts.  Paste that here, after appropriate editing if needed.  I had some issues when setting mine up, too, but I was eventually able to get around it.  I believe your second vhost entry is not being picked up, and the server is defaulting to the first vhost entry (www.mywebserve.com).

From what I've seen of your previous examples, your only issues were the lack of NameVirtualHost, and the demo vhost should be:

<VirtualHost *:80>
  ServerName demo.mywebserver.com
  # ...other stuff
</VirtualHost>
0
 
LVL 1

Author Comment

by:Wrathyimp
ID: 17159000
Thank Routinet,

This the output of the command http2 -S:
Creating new config (0x80deb00) for (null)
VirtualHost configuration:
xxx.xxx.xxx.xxx:80      demo.mywebserver.com (/etc/apache2/vhosts.d/demo_vhost.conf:7)
wildcard NameVirtualHosts and _default_ servers:
*:80                   www.mywebserver.com (/etc/apache2/vhosts.d/default_vhost.conf:7)
Syntax OK
Destroying config 0x80deb00

There is an IP (static) defined to the demomywebserver.com, even with the IP, i am going to the www.mywebserver.com page.
Any other conf file to be modified. The http2.conf has a line mention for the following:
## 'Main' server configuration ##
Include /etc/apache2/default-server.conf

and for virtual host it has the following:
### Virtual server configuration ##
Include /etc/apache2/vhosts.d/*.conf

Does the about main server line affect teh vhost configuration.

Thank You once again.


0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 50 total points
ID: 17161963
A couple things to check:

1) Is the IP used in (/etc/apache2/vhosts.d/demo_vhost.conf:7) the same IP returned by DNS for demo.mywebserver.com?
2) Are you listening  on that IP?  (Listen directive)
3) Try changing your vhost directive for demo to <VirtualHost *:80>
4) Try ensuring the demo declaration is read first.  Does that change any behavior?
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now