[thelist] Configuring Apache 2, PHP5, and virtual hosts

Phil Turmel pturmel-webdev at turmel.org
Mon Nov 13 18:56:11 CST 2006


Brooking, John wrote:
> Help! I'm a coder, not an admin, and I'm tearing my hair out trying to
> configure my local Apache 2.2 (Windows) server to run PHP5 with virtual
> hosts! I've looked at a lot of documentation and tutorials, but not much
> seems to address the PHP and virtual host combination.
> 
> Maybe complicating matters, I seem to be running PHP as a CGI, because
> those were the instructions that I was able to get to work before I
> started trying to add in virtual hosts. I was not able to get it working
> as a module using php5apache2.dll. That file is present, but for some
> reason the LoadModule statement for it was preventing Apache from
> starting, and I never did figure out why. I don't know if this is part
> of my primary problem or not.
> 
> Anyway, as a CGI, I was finally able to get PHP working under the
> default document root, and part of that involved setting PHP's doc_root
> to match Apache's DocumentRoot. But when I added a virtual host, PHP
> would not work in that site, still only in the default site. So I gave
> up on that for the moment and tried switching Apache's default document
> root to the new area, and it still would not work. I finally realized
> (after spending 1/2 hour composing my first message to this list, which
> I never sent) that if I *also* changed PHP's doc_root to match up with
> Apache's new DocumentRoot, it works!
> 
> But, if I have virtual hosts, I can't also have multiple settings for
> doc_root in php.ini, can I? How is that supposed to work in a virtual
> host environment? This is the information I can't seem to find. Or maybe
> after several hours just getting this far, I'm tired of searching and
> thinking, and just need to ask if anyone here has the answer. :-|
> 
> Any advice is appreciated, thanks in advance.
> 
> - John

John,

I haven't run Apache on Windows in a long time, but IMS, you don't need
to set doc_root in php.ini at all, unless for some unusual reason you
also need cgi.force_redirect = 0.

And if you do need it, try to set it from apache using the php_value
directive in each virtualhost.

http://www.php.net/manual/en/security.cgi-bin.php
http://www.php.net/manual/en/configuration.changes.php

HTH,

Phil




More information about the thelist mailing list