#native_company# #native_desc#
#native_cta#

Two PHP’s are better than one Page 3

By Michael Galloway
on August 19, 2002

Step Three: Modifying
Apache
Here is where the magic comes in. This
took myself and a couple other guys (Thanks Brian and Jason!) weeks
to figure out. Unfortunately (until now) nothing was on the web
about how to do it (that we could find).
The
main configuration file for Apache is httpd.conf. It controls, among
other things, the configuration for each Virtual Host (that is, each
domain) you are serving, as well as the reaction Apache should take
towards any given filename extension. First we indicate that we are
considering .php files to be special by adding a Handler (this can be
added anywhere, but for organizational purposes it is best to include
them before the Virtual Host listings).
  AddHandler php-script .php
Next we include the Action that Apache should take when
a php-script file is encountered.
  Action php-script /php/php
This is the key point. This line tells Apache that it
should execute the binary at the relative location (as this is in
reference to the DocumentRoot setting in the VirtualHost section for
each domain) and feed in the requested PHP file.
Since Apache considers every request relative to the
DocumentRoot (which in our case is htdocs) we will need to add two
ScriptAliases to allow the process to proceed.
  ScriptAlias /php/ /www/clients/myEcommerceSite/php/
  ScriptAlias /php/
/www/clients/myEcommerceSite/php/*/
So the
result of it is when a client requests catalog.php from
myEcommerceSite, Apache accesses the file and sends it through the
binary (or link) called php located at:
/www/clients/myEcommerceSite/php/
Once the PHP
binary is finished with the page it is transmitted to the user, just
as it normally would be with an Apache module.
Restart the Apache server and you are ready to go. All
you need to do is change which PHP build any given site is linked to
and you can adjust which interpreter is used!
Now you can break PHP all day long!
< Michael >