LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-20-2005, 12:29 PM   #1
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Rep: Reputation: 0
Apache Virtual Host problem - DNS or DHCP issue?


hi all,

having trouble setting up virtual hosts on my machine.

intro:
suse 9.2 pro
apache2
laptop
internal NIC gets address via DHCP
pcmcia wireless NIC gets address via DHCP
trying to do this w/o YaST so I know exactly what files are getting changed and how.

I'm trying to set up name-based virtual hosting. in my httpd.conf file i have the default server set as such (in default-server.conf):
===============================
ServerName ortiz
DocumentRoot "/srv/www/htdocs"
ServerAdmin root@mymachine.us

#
# Configure the DocumentRoot
#
<Directory "/srv/www/htdocs">
Options Indexes Includes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
/=================================

And in my virtual hosts file i have this in vhosts.d/local-sites.conf

=================================
NameVirtualHost *

<VirtualHost *>
ServerName localhost
ServerAlias ortiz
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost *>
DocumentRoot /srv/www/nthdegree/public_html
ServerName nthdegree
ServerAdmin this@this.com
# Other directives here

</VirtualHost>
/=================================

SO.... The default host works fine and it serves up all the pages below the default document root. But when I try to look at //nthdegree/ it won't find the site. I put an IP address into /etc/hosts for nthdegree, but the browser still says "the connection was refused when trying to contact nthdegree".

I know the local-sites.conf file is getting loaded because at some point messing around w/ the hosts files I got the server to spit out a 403 error when trying to hit //nthdegree, which prints out the host name and serverAdmin email address. Checking on the 403 error, I figured out that I did not have a permissions issue because files under the default documentRoot with the same permissions and ownership can be seen in a browser.

I don't have much experience setting up apache, but my old apache 1.3 config (IP-based) worked fine. When I needed to add a new virtual host, I'd add the virtual host info in httpd.conf and add an IP address in /etc/hosts and it would show up. I moved to name-based hosts because I figured my laptop would be getting DHCP addresses and I shouldn't rely too much on IP-based configurations.

So, I don't know if I need to add something to my hosts files or DNS entries or what, or what files need to be changed so that the new virtual hosts are resolved. Been hacking away at this for hours and can not figure it out. Any help is much appreciated.

-Russell
 
Old 03-20-2005, 12:31 PM   #2
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
and another thing...

I noticed when I was messing around w/ my hosts files that DHCP automatically updates some files. I can turn this setting off, but I'm not sure if this is what is causing the problem.
 
Old 03-20-2005, 12:32 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What did you put in your hosts file?
127.0.0.1 nthdegree
 
Old 03-20-2005, 01:02 PM   #4
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
this is my current hosts file:
====================================
127.0.0.1 ortiz.reno.nv.us ortiz

# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts


# apache2 virtual hosts
#
127.0.0.2 linux.site linux
127.0.0.3 nthdegree
/===================================

ortiz is the machine name and default host. that all works fine.

linux.site i think is something Yast threw in there at some point. //linux points to the default documentRoot via a server alias.

I Just stuck in the 127.0.0.3 address and now I get a 403 error "Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server." But I'm pretty sure it's not a permissions issue. At some point when I was setting up IP-based virtual hosts I got my nthdegree site to come up fine, so I believe apache can read the files. But after I rebooted I think DHCP did something to my hosts files and so I decided to set up name-based virtual hosts instead.
 
Old 03-20-2005, 01:05 PM   #5
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Is there a reason you are wanting to use multiple IP addresses?
 
Old 03-20-2005, 01:05 PM   #6
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
tried '127.0.0.1 nthdegree' in hosts but same 403 error.

403 erorr shows nthdegree as the host in the error msg. and the correct webmaster email address from the nthdegree virtual host entry.
 
Old 03-20-2005, 01:07 PM   #7
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
i don't want to use multiple IPs. i was thinking it was a hosts issue so that's where i've been flailing around.

when i put an entry in for nthdegree i get the 403 error. when there's no entry, i don't get anything. so i figured i was closer w/ the hosts file than anything else i was trying.
 
Old 03-20-2005, 01:11 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
OK, if you don't need multiple IPs then just set them all to the loopback:
127.0.0.1 localhost nthdegree domain1 domain2 etc

If you are getting 403 errors then you have got the hosts bit working but apache is refusing to show you the document you are accessing. Do you have an index file in place? If so then make sure the webserver has permision to read it.
 
Old 03-20-2005, 01:21 PM   #9
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
thanks for the hosts tip

can i have them on separate lines or will hosts get confused?

ie
127.0.0.1 localhost
127.0.0.1 nthdegree

etc.



strange thing, i'm still getting the 403 error. all the files in the virtual host directory are owned the same and have the same permissions as the default host.
 
Old 03-20-2005, 01:26 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
They should all be on one line.

Can you post the output from:
ls -la /srv/www/nthdegree/public_html

Also, can you post any messages that show up in your apache error_log when you try to access the virtual host.
 
Old 03-20-2005, 01:34 PM   #11
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
linux:/home/russell # ls -al /srv/www/nthdegree/public_html/
total 105
drwxrwxr-x 11 russell 500 808 2005-03-20 09:54 .
drwxr-xr-x 9 russell 500 408 2005-03-15 16:11 ..
drwxrwxr-x 9 russell 500 2120 2005-03-15 16:14 catalog
drwxrwxr-x 3 russell 500 192 2005-02-02 17:01 cgi-bin
-rw-r--r-- 1 russell 500 5464 2005-02-21 21:51 contact.php
-rw-r--r-- 1 russell 500 155 2005-02-25 15:29 contact_success.php
drwxrwxr-x 2 russell 500 160 2005-03-16 07:33 CVS
-rw-r--r-- 1 russell 500 11169 2005-02-25 15:27 dealer_application.php
-rw-r--r-- 1 russell 500 158 2005-02-25 15:27 dealer_app_success.php
drwxrwxr-x 3 russell 500 144 2005-02-28 09:48 docs
-rw-rw-r-- 1 russell 500 6168 2005-02-24 10:03 faq.php
-rw-rw-r-- 1 russell 500 894 2005-01-31 22:16 favicon.ico
drwxrwxr-x 3 russell 500 232 2005-02-11 17:25 front_page_images
-rwxrwxr-x 1 russell 500 116 2005-03-15 15:12 .htaccess
drwxrwxr-x 4 russell 500 808 2005-02-23 05:28 images
-rw-rw-r-- 1 russell 500 868 2005-01-31 22:16 index_dev.html
-rw-r--r-- 1 root root 21 2005-03-20 09:54 index.html
-rw-r--r-- 1 russell 500 6008 2005-02-17 16:35 index.php
-rw-rw-r-- 1 russell 500 19 2005-01-31 22:16 info.php
-rw-rw-r-- 1 russell 500 10240 2005-02-03 14:33 local.tar
-rw-rw-r-- 1 russell 500 9059 2005-02-27 13:52 locator.php
-rw-rw-r-- 1 russell 500 144 2005-02-09 20:54 news.php
-rw-rw-r-- 1 russell 500 844 2005-03-11 16:14 print_button_page.php
drwxrwxr-x 8 russell 500 1560 2005-03-08 15:55 storeadmin
drwxrwxr-x 3 russell 500 112 2005-02-02 17:01 style
drwxrwxr-x 3 russell 500 872 2005-02-26 19:12 templates
-rw-rw-r-- 1 russell 500 143 2005-02-09 20:54 who.php
linux:/home/russell # ls -al /srv/www/htdocs/test
total 5
drwxr-xr-x 2 root root 80 2005-03-20 11:29 .
drwxr-xr-x 26 root root 1080 2005-03-20 11:28 ..
-rw-r--r-- 1 root root 20 2005-03-20 11:29 index.html


=====================================

i threw in the ls -al /srv/www/htdocs/test to show that //ortiz/test/index.html is showing up fine, and it has the same permissions as the virtual host directory.
 
Old 03-20-2005, 01:40 PM   #12
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Yet if you access this you still ge a 403:
http://nthdegree/index.html

Are there any errors in the error_log file?
 
Old 03-20-2005, 01:50 PM   #13
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
[Sun Mar 20 11:27:44 2005] [error] [client 127.0.0.1] client denied by server configuration: /srv/www/nthdegree/public_html/
[Sun Mar 20 11:27:45 2005] [error] [client 127.0.0.1] client denied by server configuration: /srv/www/nthdegree/public_html/favicon.ico
[Sun Mar 20 11:34:35 2005] [error] [client 127.0.0.1] client denied by server configuration: /srv/www/nthdegree/public_html/index.html
 
Old 03-20-2005, 01:58 PM   #14
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Ok, in your nthdegree virtualhost directive - try adding:
<Directory /srv/www/nthdegree/public_html>
Order Allow,Deny
Allow from all
</Directory>

Then restart apache and try the host again.
 
Old 03-20-2005, 02:04 PM   #15
costrevs
LQ Newbie
 
Registered: Mar 2005
Posts: 13

Original Poster
Rep: Reputation: 0
THAT DID IT!!

my goodness, thank you much.
 
  


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
Virtual Host issue with apache gauge73 Linux - Networking 1 07-12-2005 02:00 PM
Apache Virtual Host Problem eckertc1 Linux - Newbie 11 03-23-2005 03:31 PM
Apache Virtual Host problem Seventh Linux - Software 2 03-19-2005 06:33 PM
Apache virtual host problem Adrohak Linux - Software 3 07-18-2004 04:17 PM
Virtual Host Problem using Apache ataber Linux - Newbie 2 01-27-2003 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:51 AM.

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