PHPBuilder - Two PHP's are better than one Page 3

RSS Twitter

Two PHP's are better than one - Page 3

by: Michael Galloway
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 >

« Previous Page

Comment and Contribute

Your comment has been submitted and is pending approval.

Michael Galloway



(Maximum characters: 1200). You have characters left.