LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-12-2009, 12:07 PM   #1
djroy
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Apache virtualhost with 2 ip's


Hello,

I have Apache 2.2.14 on Suse linux 10.3.
That's is ok, and works fine.

Now come's the problem, i have 2 ip addresses, and 2 domains.
Now must Apache listen on the first ip, for the first domain.
And the second ip for the second domain.

But, if i go to the second domain in my browser i will come on the first domain out.

Example:

ip1: 192.168.100.210
Domain1: first-domain.com

ip2: 192.168.100.211
Domain2: second-domain.com

This is my httpd-vhosts
Code:
#NameVirtualHost *:80

<VirtualHost 192.168.100.210:80>
    DocumentRoot "/usr/local/apache2/htdocs"
    ServerName first-domain.com
    ServerAlias www.first-domain.com
</VirtualHost>

<VirtualHost 192.168.100.211:80>
    DocumentRoot "/home/roy/public_html/second-domain.com"
    ServerName second-domain.com
    ServerAlias www.second-domain.com
</VirtualHost>
This does not work correctly.
When i both IP addresses replace with a wilcard (*) , then it's will works fine.

Can any one my help me?
I don't see what i did wrong...
 
Old 10-12-2009, 12:35 PM   #2
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
you should uncomment the following line.

#NameVirtualHost *:80

to

NameVirtualHost *:80

This is the line that allows for multiple domains to be hosted on the same port...
 
Old 10-12-2009, 01:48 PM   #3
djroy
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
I think i have found the solution...

This is now the httpd-vhosts.conf

Code:
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache2/htdocs"
    ServerName first-site.com
    ServerAlias www.first-site.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/home/roy/public_html/second-site.com"
    ServerName second-site.com
    ServerAlias www.second-site.com
</VirtualHost>

<VirtualHost 192.168.100.211:80>
    DocumentRoot "/home/roy/public_html/second-site.com"
    ServerName second-site.com
    ServerAlias www.second-site.com
</VirtualHost>

<Directory /home/roy/public_html/second-site.com>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
The first-site.com shows now the first site, and second-site.com shows the second site, on the second ip.

192.168.100.210 shows now the first site, and is the default, all other sites (that not defined is in the config) goes to the first site

192.168.100.211 shows now the second site.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache VirtualHost QS helptonewbie Linux - Server 6 07-22-2009 11:33 AM
apache problems with virtualhost ... mediolanum Linux - Networking 1 04-09-2006 06:01 AM
Apache -VirtualHost davidhk Debian 7 08-19-2005 12:33 PM
Help with Apache <VirtualHost> please. smakkythecamel Linux - Networking 2 06-12-2003 07:15 PM
apache virtualhost jonfa Linux - Networking 5 08-12-2002 06:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration