Re: [PHP-INSTALL] Weird virtual host error

[email protected] (Keith Roberts)
Newsgroups php.install
Message-ID <[email protected]>
On Mon, 21 Jul 2008, Richard Heyes wrote:

> To: [email protected]
> From: Richard Heyes <[email protected]>
> Subject: [PHP-INSTALL] Weird virtual host error
> 
> Hi,
>
> Got a strange error to do with Apache and virtual hosts. 
> http://www.bioscience.co.uk and http://staging.bioscience.co.uk are both 
> the same machine and PHP is clearly working on the default (www...) but 
> not on the (only) virtual host (staging...)
>
> The virtual host config is thus:
>
> <VirtualHost 62.233.101.227:80>
>        ServerName staging.bioscience.co.uk
>
>        DocumentRoot /var/www/vhosts/staging/htdocs
>
>        CustomLog logs/staging.bioscience.co.uk-access_log combined
>        ErrorLog logs/staging.bioscience.co.uk-error_log
> </VirtualHost>
>
> Is this even correct? Thanks.
>
> -- 
> Richard Heyes
> http://www.phpguru.org

Hi Richard. Maybe you would like to use my httpd.conf VH 
definitions as a template to setup your own VH?

# virtual host definitions

# needs to be the IP number of the network card interface
# NOT my public IP address 81.168.74.150
NameVirtualHost 10.0.0.1

#-----------------------------------------------------------------

# default virtual host

#<VirtualHost 10.0.0.1>
#  ServerName www.karsites.net
#</VirtualHost>

# default virtual host - karsites

<VirtualHost 10.0.0.1>
# any required directives not set in this VH container
# will default to the global values
# set outside this or any other VH containers
   ServerName www.karsites.net
   ServerAlias karsites.net
   DocumentRoot /websites/live/karsites
</VirtualHost>

<Directory /websites/live/karsites>
   # DirectoryIndex /home/anyuser/newsite-ETA.php
   DirectoryIndex /home/anyuser/home.php
   Options None
   Order deny,allow
   Allow from all
   php_admin_flag display_errors OFF
</Directory>

#-----------------------------------------------------------------
# virtual host www.php-debuggers.net

<Directory /websites/live/php-debuggers>
   # DirectoryIndex /home/anyuser/newsite-ETA.php
   DirectoryIndex /home/anyuser/home.php
   Options None
   # Options Indexes
   Order deny,allow
   Allow from all
   php_admin_flag display_errors OFF
</Directory>

<VirtualHost 10.0.0.1>
   ServerName www.php-debuggers.net
   ServerAlias php-debuggers.net
   ServerAdmin [email protected]
   DocumentRoot /websites/live/php-debuggers
</VirtualHost>

#-----------------------------------------------------------------
# virtual host www.raised-from-the-dead.org.uk

<Directory /websites/live/raised-from-the-dead>
   # DirectoryIndex /home/anyuser/newsite-ETA.php
   DirectoryIndex /home/anyuser/home.php
   Options None
   # Options Indexes
   Order deny,allow
   Allow from all
   php_admin_flag display_errors OFF
</Directory>

<VirtualHost 10.0.0.1>
   ServerName www.raised-from-the-dead.org.uk
   ServerAlias raised-from-the-dead
   ServerAdmin [email protected]
   DocumentRoot /websites/live/raised-from-the-dead
</VirtualHost>

and my /etc/host file looks like:

# Fedora 8 /etc/host file
#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# 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

10.0.0.1        www.karsites.net   karsites.net  karsites
10.0.0.1        www.php-debuggers.net   php-debuggers.net 
php-debuggers
10.0.0.1        www.raised-from-the-dead.org.uk 
raised-from-the-dead.org.uk
10.0.0.1        raised-from-the-dead

Using the above domain name mappings allows me to access my 
virtual host definitions from localhost. Without these 
mappins my machine would try an internet DNS lookup on my 
own hostnames - which will not work.

HTH

Keith Roberts

-----------------------------------------------------------------
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

The mind of the prudent is ever getting knowledge, and the
eear of the wise is ever seeking, inquiring for and craving
knowledge. Pr. 18:15 Amp

All email addresses are challenge-response protected with
TMDA [http://tmda.net]
-----------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.