Solved

Vhost configuration

Posted on 2006-07-15
10
772 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

739 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