Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got Apache 2.2 working, and my virtualhosts work within the following directories:

C:/www (main Apache root)

C:/www/vhosts (virtual hosts)

However, I cannot get PHP files to function outside of vhosts, even if the domain works well as a virtual host.

Example domain:

<VirtualHost *:80>
    ServerName  testweb1.co.uk
              ServerAlias  www.testweb1.co.uk
    DocumentRoot /www/testweb1.co.uk
    ErrorLog /www/Apache22/logs/error.log

<Directory "/www/testweb1.co.uk">
    Options All
    AllowOverride All
    order allow,deny
    allow from all

I tried a PHP file with a simple include, two files in the directory:

<?php include("header.php"); ?>

It worked within C:/www/vhosts but outside of it, no PHP code was displayed.

Here's my vhosts-conf, well, the beginning:

<Directory C:/www/>   
Order Deny,Allow   
Allow from all 
<Directory C:/www/mytest61>   
Order Deny,Allow   
Allow from all 

Why is this and what can be done? PHP scripts won't execute in either of them.

I don't want all my virtualhosts in one directory; what's the best solution for this?

share|improve this question

migrated from stackoverflow.com Jul 9 '11 at 2:22

This question came from our site for professional and enthusiast programmers.

Check php setting for base directory –  SergeS Jul 8 '11 at 14:31
How is PHP being enabled in apache? If the AddHandler directive is inside a <Dir /www/vhosts>, then PHP would only function inside that directgory. –  Marc B Jul 8 '11 at 14:32
It would help if your code examples would line up. You say you have two local directories but your config files have references to different (non existing) local directories. –  Adrian Jul 8 '11 at 15:30
See if you have inserted AddType application/x-httpd-php .php and LoadModule php5_module modules/libphp5.so main Apache root configuration. –  tftd Jul 9 '11 at 3:07
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.