note 60737 added to install.windows
| From: | lukasz at szostak dot biz | Date: | Sun, 15 Jan 2006 15:50:57 +0000 |
| Subject: | note 60737 added to install.windows | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-101853@lists.php.net to get a copy of this message | ||
You can have multiple versions of PHP running on the same Apache server. I have seen many different
solutions pointing at achieving this, but most of them required installing additional instances of
Apache, redirecting ports/hosts, etc., which was not satisfying for me.
Finally, I have come up with the simplest solution I've seen so far, limited to reconfiguring
Apache's httpd.conf.
My goal is to have PHP5 as the default scripting language for .php files in my DocumentRoot (which
is in my case d:/htdocs), and PHP4 for specified DocumentRoot subdirectories.
Here it is (Apache's httpd.conf contents):
---------------------------
# replace with your PHP4 directory
ScriptAlias /php4/ "c:/usr/php4/"
# replace with your PHP5 directory
ScriptAlias /php5/ "c:/usr/php5/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php5/php-cgi.exe"
# populate this for every directory with PHP4 code
<Directory "d:/htdocs/some_subdir">
Action application/x-httpd-php "/php4/php.exe"
# directory where your PHP4 php.ini file is located at
SetEnv PHPRC "c:/usr/php4"
</Directory>
# remember to put this section below the above
<Directory "d:/htdocs">
# directory where your PHP5 php.ini file is located at
SetEnv PHPRC "c:/usr/php5"
</Directory>
---------------------------
This solution is not limited to having only two parallel versions of PHP. You can play with
httpd.conf contents to have as many PHP versions configured as you want.
You can also use multiple php.ini configuration files for the same PHP version (but for different
DocumentRoot subfolders), which might be useful in some cases.
Remember to put your php.ini files in directories specified in lines "SetEnv PHPRC...",
and make sure that there's no php.ini files in other directories (such as c:\windows in
Windows).
And finally, as you can see, I run PHP in CGI mode. This has its advantages and limitations. If you
have to run PHP as Apache module, then... sorry - you have to use other solution (the best advice as
always is: Google it!).
Hope this helps someone.
----
Manual Page -- http://www.php.net/manual/en/install.windows.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60737
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60737&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60737&report=yes
Search -- http://master.php.net/manage/user-notes.php