[Wylug-help] setting up Apache for virtual hosts for LAN only access

James Holden wylug at jamesholden.net
Thu Dec 23 08:38:45 GMT 2004


On Wed, 2004-12-22 at 18:31, Mike wrote:
> After a deathly wall of silence on the SSL question, can anyone help
> with the following? I am trying to set up virtual hosts on Apache 1.3.33
> to serve for testing purposes 4 web sites (number could grow). I've read
> loads of stuff, hard copy and on the web, including the manual. I'm
> trying to set it up so I can view the
> sites from either of the other two machines on the network, but not to
> go out to the public. After a lot of messing about, I've got as far as
> the following error message when using test.php, which at least is
> showing the script to be where I put it!:
>
> Warning: Unknown(/usr/local/web/vhost/test.php): failed to open stream:
> Permission denied in Unknown on line 0

Chekc the permissions on the file and the directory it's in. It must be
readable by the user the webserver is running as, which could be one of
www, apache, httpd or nobody, depending on your OS.

> Warning: (null)(): Failed opening '/usr/local/web/vhost/test.php' for
> inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0

Symptoms as above.

> When I try and enter any of the sites, e.g. http://duke/anysite I get a
> permission error. I've put a <Directory> block inside the <Virtual Host>
> block to try and overcome it, but without joy so far.

Directory blocks don't go inside the VirtualHost blocks. You don't nest
blocks in httpd.conf AFAIK.

> The php error suggests to me I should be doing something in php.ini? Or
> is that one more of Linux's red herrings?

It's just letting you know where else it looked.

> I made the directories in /usr/local/ from /web onwards myself, because
> in spite
> of what the manual says there was not one there. Web browsing has told
> me that those directories often come under /var/www/ but, although that
> directory exists, none of the files or directories I am led to believe
> should be there are actually there! I built Apache from .tar.gz
> download, with --enable-modules=most and --shared-module=max, then
> php.4.3.8 with apxs and a load of other things.

You need to have the following in your httpd.conf:

# To enable virtual host on port 80 of all interfaces
NameVirtualHost *:80

# To set the base path for the server
ServerRoot /var/local # (if that's where you're creating directories)

# For each virtual host
<VirtualHost *:80>
	ServerName whatever
	DocumentRoot /path/to/the/documentroot/of/whatever
	ErrorLog logs/whatever-error_log # optional
	# Other, vhost specific options
</VirtualHost>

# Also, if apache is set up tightly
<Directory "/path/to/the/documentroot/of/whatever">
	Order Allow, Deny
	Allow from All
</Directory>

Don't forget to add entries into your hosts file or DNS for the virtual
hosts.

Set the permissions on those directories you created. They shouldn't be
owned by the apache user, but should be readable. The log files,
however, must be writeable by the apache user.

> Oh, yes, there is one more thing: If I type into the browser command
> line something like http://nameofsubdir I get the following URL
> appearing:

That'll be your browser returning the first Google search result for
'nameofsubdir'.


James

> https://exchange.1and1.com/exchweb/bin/auth/owalogon.asp?url=https://exchange.1and1.com/exchange&reason=0
> How on earth do I get M$ sticking its ugly snout in? And not an M$
> programme in site on my machine!
>
> All suggestions regarding the Apache problem gratefully received.
>
> Season's greetings to all, and whatever you wish yourselves for '05.
>
> Best regards,
>
> Mike Goodman
>
>
>
> _______________________________________________
> Wylug-help mailing list
> Wylug-help at wylug.org.uk
> http://list.wylug.org.uk/mailman/listinfo/wylug-help




More information about the Wylug-help mailing list