LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-27-2005, 07:37 AM   #1
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Rep: Reputation: 15
my newbie apache problem


Hello ...

I have a strange problem, I think it will be quite easy for you to solve, but I really tried many things with it and I just couldn't figure out the solution.

first take a look at these 2 files


here's /etc/hosts (I don't have a DNS)

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
127.0.0.1 abbas.jackandmido.com abbas
127.0.0.1 happy.jackandmido.com happy



here's my /etc/httpd/conf/httpd.conf

<VirtualHost *>
ServerAdmin webmaster@blabla.com
DocumentRoot /var/www/marsguy
ServerName abbas.jackandmido.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost *>
ServerAdmin webmaster@blabla.com
DocumentRoot /var/www/html/mango
ServerName happy.jackandmido.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>


these domains are just for test, they don't really exist.

the problem is: when I type "abbas.jackandmido.com" or "happy.jackandmido.com" I get the same page which is located in "/var/www/marsguy" (the first in order)!!!

I really wanna know why does this happen?
please help me!
thanks in advance
 
Old 03-27-2005, 07:44 AM   #2
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Rep: Reputation: 30
You need to increment the number like so

127.0.0.1 localhost.localdomain localhost
127.0.0.2 abbas.jackandmido.com abbas
127.0.0.3 happy.jackandmido.com happy
 
Old 03-27-2005, 08:14 AM   #3
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Original Poster
Rep: Reputation: 15
Hello spoody_goon

thanks for your help

but I don't think that the problem is with the /etc/hosts.conf, I think the problem is with the httpd.conf

again, thanks for your help.

I really wish somebody could help me find the answer soon!

thanks
 
Old 03-27-2005, 09:53 AM   #4
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Rep: Reputation: 30
Hmm. well it does seem that I did missed something.
Try this

# /etc/hosts
127.0.0.1 localhost.localdomain localhost
127.0.0.2 abbas.jackandmido.com abbas
127.0.0.3 happy.jackandmido.com happy

# /etc/httpd/conf/httpd.conf
NameVirtualHost 127.0.0.2
<VirtualHost 127.0.0.2>
ServerName abbas.jackandmido.com
ServerPath /var/www/
DocumentRoot /var/www/marsguy
</VirtualHost>

NameVirtualHost 127.0.0.3
<VirtualHost 127.0.0.3>
ServerName happy.jackandmido.com
ServerPath /var/www/
DocumentRoot /var/www/html/mango
</VirtualHost>

This is the format I use to test web sites on my pc w/apache it should work
 
Old 03-28-2005, 02:43 AM   #5
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Original Poster
Rep: Reputation: 15
Hello spoody_goon

Thanks for helping me.

I know your method will work just fine, but I wanted to host several web sites using the same IP address.

I tried some stuff and finally found a solution:

the solution is to assign your webserver's IP address to the NameVirtualHost directive. like so

this is the new httpd.conf and it is working perfectly.

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
DocumentRoot /var/www/html/marsguy
ServerName abbas.jackandmido.com
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot /var/www/html/mango
ServerName happy.jackandmido.com
</VirtualHost>


Thanks
 
Old 03-28-2005, 09:20 AM   #6
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Rep: Reputation: 30
sorry I wasn't of more help, I don't know how to do that.
 
Old 03-28-2005, 09:45 AM   #7
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
marsguy: Referring to the httpd.conf lines in your first post of this thread, did you try just uncommenting the directive “NameVirtualHost *” in httpd.conf? That’s all you should need to do to enable name-based Virtual Hosts in Apache 2.
 
Old 03-28-2005, 11:30 AM   #8
marsguy
Member
 
Registered: Nov 2004
Distribution: Red Hat Enterprise & SuSe 10
Posts: 77

Original Poster
Rep: Reputation: 15
hello WhatsHisName!

how are you doing?

yes I uncommented the directive “NameVirtualHost *” in httpd.conf since the very beginning!

I know this looks weird!

thanks
 
Old 03-28-2005, 07:02 PM   #9
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHEL, AltimaLinux, Rocky
Posts: 1,151

Rep: Reputation: 46
marsguy: The listing below came out of a working FC3 Name-based Apache 2.0 system (httpd-2.0.52-3.1) using a single IP address:

The domain names were changed to name1.org, name2.org and name3.org, where the Fully Qualified Domain Names are www2.nameX.org (“redirects”).


Snippets from httpd.conf (obviously not the entire file):

Listen *:80
Listen *:8080

ServerName 127.0.0.1

DocumentRoot "/var/www/html" #Not used, just left in place

#HUGE GAP

NameVirtualHost *:80
NameVirtualHost *:8080

LockFile "/var/lock/httpd.lock"
CoreDumpDirectory "/etc/httpd"

# Virtual Default Host name1 (This is the main site)
<VirtualHost *:80 *:8080>
DocumentRoot /var/www/html/name1/
ServerAdmin root@localhost
ServerSignature email
Directorylndex index.php index.html index.htm index.shtml
LogLevel debug
HostNameLookups off
</VirtualHost>

# Virtual host name2
<VirtualHost *:80 *:8080>
DocumentRoot /var/www/html/name2
ServerAdmin root@localhost
ServerName www2.name2.org
ServerAlias name2.org
ServerAlias www.name2.org
ServerAlias *.name2.org
Server Signature email
Directorylndex index.html index.htm index.shtml
</VirtualHost>

# Virtual host name3
<VirtualHost *:80 *:8080>
DocumentRoot /var/www/html/name3
ServerAdmin root@localhost
ServerName www2.name3.org
ServerAlias name3.org
ServerAlias www.name3.org
ServerAlias *.name3.org
Server Signature email
Directorylndex index.html index.htm index.shtml
</VirtualHost>

Hope that helps.
 
  


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 authorization problem (im a newbie) plz help very urgent ruslan40321 Linux - Networking 6 06-17-2005 10:00 PM
Problem with Apache [newbie] Samspeed Linux - General 2 07-25-2003 07:50 AM
Apache 2.0 newbie problem Neorio Linux - Networking 2 06-03-2003 02:20 PM
Newbie with Apache sienarot Linux - Newbie 5 03-13-2003 12:28 PM
newbie apache problem kurgan70 Linux - General 2 06-18-2001 03:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:53 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