Solved

Vhost configuration

Posted on 2006-07-15
10
773 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

696 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