RE: [Nolug] php scripts virtual hosts cleaned up

From: James Scott <jhs_technical_at_cox.net>
Date: Tue, 09 Mar 2004 20:26:55 -0600
Message-Id: <1078885614.5048.283.camel@example1.com>

First this cleaning up thing is a pain. I am going to attempt to get
the relevant stuff in here.

First the problem. I attempted to set up virtual hosts on my fc1
server. I only want to see them internally as a test bed. I failed. I
used a textbook example even. I must have skipped something but I
cannot find it. After reading Pietu's very helpful input I tried a
whole bunch of stuff including using his virtual container syntax line
for line changing only the names. I tried only having one virtual host
and still the only thing I could get to display in the target
directories was the default page and phpinfo. I put the original
httpd.conf file back and moved the index.html file I had for a trial
into /var/www/html/ and voila, it works. So everything works fine in
the default directory. The question remains what am I doing wrong?

corresponding manual
page:http://httpd.apache.org/docs-2.0/vhosts/examples.html#serverpath

the section heading:

"Running several name-based web sites on a single IP address."
excerpt from file:

Here is the first example virtual host container:

NameVirtualHost *

<VirtualHost *>
DocumentRoot /var/www/example1
ServerName www.example1.com

AddType application/x-httpd-php .php
DirectoryIndex index.php
</VirtualHost>

<VirtualHost *>
DocumentRoot /var/www/example2
ServerName www.example2.org

# Other directives here
AddType application/x-httpd-php .php
DirectoryIndex index.php
</VirtualHost>

And the paths were:
/var/www/example1 and example2
Start up errors were:
"Starting httpd: [Tue Mar 09 10:45:02 2004] [error] VirtualHost
_default_:443 -- mixing * ports and non-* ports with a NameVirtualHost
address is not supported, proceeding with undefined results"

Attempting to access files html or php gave me these sort of log
entries.
log errors:

 [Mon Mar 08 16:27:56 2004] [error] [client 68.11.44.133] Directory index forbidden by rule: /var/www/html/
 [Mon Mar 08 16:32:36 2004] [error] [client 68.11.44.133] File does not exist: /var/www/html/admin
 [Mon Mar 08 16:50:05 2004] [error] [client 68.11.44.133] Directory index
 forbidden by rule: /var/www/html/ script not found or unable to stat script not found or unable to stat
 [Mon Mar 08 17:31:19 2004] [error] [client 68.11.44.133] File does not exist: /var/www/html/new_downloads

The next try:
NameVirtualHost "actual ip address of localhost"

<VirtualHost example1.com "actual ip address of localhost">
ServerAdmin webmaster@localhost
ServerName example1.com
ServerAlias *.example1.com
DocumentRoot /var/www/example1
CustomLog /etc/httpd/logs/access_log combined
</VirtualHost>

And I also tried it with 127.0.0.0 net addresses. I believe I would
have to set routes for those to use them and I cannot remember how now.
Fried. Should work though. After all it is a vacant set of addresses
save one and all internal.

In the end these are the errors produced:
[Tue Mar 09 14:16:24 2004] [error] [client 68.11.44.133] Invalid method
in request \x16\x03
[Tue Mar 09 14:16:52 2004] [error] [client 68.11.44.133] Invalid method
in request \x80g\x01\x03
[Tue Mar 09 14:20:21 2004] [error] [client 68.11.44.133] Invalid method
in request \x80g\x01\x03
[Tue Mar 09 14:20:26 2004] [error] [client 68.11.44.133] File does not
exist: /var/www/example1/index.html

Pietu: The errors you are seeing in the logs, I've seen them in the
cases where I had incorrectly configured path to the website in my
httpd.conf file OR when I did not have all the correct index files
listed in httpd.conf

Jim: This is exactly what I think the problem is.
 Jim's path:
The path:/var/www/example1/html
Path 2: /var/www/example2/html

"Starting httpd: [Tue Mar 09 10:45:02 2004] [error] VirtualHost
_default_:443 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results"
  
___________________

Pietu response: I've never succeeded with those * asterixes in httpd.conf
Jim: I think I can see why. I am not liking it either.
Pietu response and original example:

NameVirtualHost 10.255.178.2

<VirtualHost 10.255.178.2 127.0.0.2>
        ServerAdmin webmaster@localhost
        ServerName myserver.cmx
        ServerAlias *.myserver.cmx
        ServerAlias mycron #local 127.0.0.2
        DocumentRoot /var/www/myserver.cmx
        CustomLog /etc/httpd/logs/access_log combined
</VirtualHost>

This is somewhat what I'm using at home. My server internal IP is 10.255.178.2 and in my workstation hosts file I've specified "10.255.178.2 myserver.cmx" That way DNS is not involved deperately trying to find .cmx tld.
127.0.0.2 local address is there just to enable ssh tunneled access machine to see some stats and stuff. Instead of using http://localhost/ I can use http://mycron/. It is not needed in the conf.
>
Jim asked: Do you need a special directory path for this part? Not in the conf file but a www/whatever/directory.

Pietu response: No. Unless you want to make this kind of stuff in a separate directory.
Additionally I have another port for this setup, but I left it out. (For example 127.0.0.2:8880)

the conf below will also respond to www.myserver.cmx. I've never been big on limiting the address with mandatory www. subdomain, instead one is free to use both 'myserver.cmx' and 'www.myserver.cmx'
>
Jim: The entry *.myserver.cmx does this?

Pietu: Correct.
Or if you want some your sub domains to point different directories, then I would specify for example:
        ServerAlias www.myserver.cmx
        ServerAlias old.myserver.cmx

for new location of you web docs in a separate subdomain you would just create another vhost container, like:

<VirtualHost 10.255.178.2>
        ServerAdmin webmaster@localhost
        ServerName develop.myserver.cmx
        DocumentRoot /var/www/develop.myserver.cmx
        CustomLog /etc/httpd/logs/access_log combined
</VirtualHost>

folder '/var/www/myserver.cmx' has normal web read access. Or if php
needs to write something to HD then apache has the write access to
specified folder.
>
Jim asked: The write access is to the log file specified?

Pietu response: Not for this "CustomLog etc/httpd/logs/access_log
combined" This is going to /var/log/httpd/ by default.

What I meant, if you have a PHP script which need to write to
harddrive, such as some debugging information, then the file
(and/or folder) you want to write to, apache process must have
write access. (Where ever in the system this file (and/or folder)it
resides)

All the other files in your webdocument folder write accss can be
specified to whom ever is the developer.

P
Pietu response: I hope this helps a bit.
Jim: This is helping a lot.
P

___________________

___________________
Nolug mailing list
nolug@nolug.org
Received on 03/09/04

This archive was generated by hypermail 2.2.0 : 12/19/08 EST