Apache Virtual Host problem - DNS or DHCP issue?
having trouble setting up virtual hosts on my machine.
suse 9.2 pro
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):
# Configure the DocumentRoot
Options Indexes Includes FollowSymLinks
Allow from all
And in my virtual hosts file i have this in vhosts.d/local-sites.conf
# Other directives here
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.
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.
What did you put in your hosts file?
this is my current hosts file:
127.0.0.1 ortiz.reno.nv.us ortiz
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
# apache2 virtual hosts
127.0.0.2 linux.site linux
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.
Is there a reason you are wanting to use multiple IP addresses?
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.
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.
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.
thanks for the hosts tip
can i have them on separate lines or will hosts get confused?
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.
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.
linux:/home/russell # ls -al /srv/www/nthdegree/public_html/
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
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.
Yet if you access this you still ge a 403:
Are there any errors in the error_log file?
[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
Ok, in your nthdegree virtualhost directive - try adding:
Allow from all
Then restart apache and try the host again.
THAT DID IT!!
my goodness, thank you much.
|All times are GMT -5. The time now is 03:14 PM.|