Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Vhost configuration

Posted on 2006-07-15
10
Medium Priority
?
782 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 51

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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
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 51

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 51

Accepted Solution

by:
Steve Bink earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

618 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