You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Csaba Gabor <cs...@yahoo.com> on 2002/04/29 16:49:08 UTC

Instructions: Installing PHP 4.2 on Apache 2

Perhaps this will save someone the hours that it cost me to figure out how
to go from a CGI version of PHP (through 4.2) to a module version on
Apache 2 for Win2K.  What I don't understand is why the PHP install
doesn't (1) cover how to install PHP as a module for Apache2 and (2)
discuss the difference between php.exe and php-cli.exe (command line
interface or client? - take your pick).  In the discussion below,
it should be clear that you'll have to substitute your own directory
for where php lives (my root for php is the '4.2' directory)

I've had CGI versions of PHP 4 through several releases of Apache and
the setup for that is really easy (assuming they both individually work): 

0. Review php.ini (engine = On, et. al) 
1. Move php4ts.dll into appropriate windows subdirectory (for me it's
c:\winnt\System32). 

The remaining 4 items are changes/additions to Apache's httpd.conf file
(note that Apache likes forward slashes (/) instead of backslashes (\): 
2. Put index.php as the first argument to DirectoryIndex if you want
Apache to automatically pick up index.php files 

Now add the following 3 lines: 
3. AddType application/x-httpd-php .php 
4. Action application/x-httpd-php "/php4/php.exe" 
5. ScriptAlias /php4/ "c:/winapps/php/4.2/sapi/" 

3 is so Apache will know .php files are special. 4 is so Apache will know
what special program to run when it realizes it has a (.php) special file.
5 is so that Apache will know what directory that special program
(php.exe) lives in. 

To go from the CGI to the Module version should be even simpler, right?
But there is a HUGE gotcha. It's one of those You can't get there from
here syndromes if you are using Apache 2.0.28 (or earlier, I presume). I
needed to upgrade to 2.0.35 so that the required php (4.2) provided
apache2filter.dll file would work with Apache2. 

So the final steps are as follows: 
Do steps 0-3 as written above. 
If you are upgrading, not installing, then back out steps 4 and 5 from
above. 
4) Add a line to the httpd.conf file: 
LoadModule php4_module c:/winapps/php/4.2/experimental/apache2filter.dll 
NOTE that this is not the php4apache.dll file of yore in the sapi
directory (which I presume would work if you were doing this with Apache
1.3.x)

     Csaba Gabor

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Instructions: Installing PHP 4.2 on Apache 2

Posted by E�l <eo...@yahoo.com>.
Nice guide.  To answer you question on why the php
release notes don't covers this is because the PHP
people (from the site) stated 4.2 on apache2 is still
experimental with OFFICIAL support coming with 4.3
(slated for SEP02).  Glad though you provided a
walkthru though as I had been avoiding apache2 until
php was a proven thing on it.

peter

--- Csaba Gabor <cs...@yahoo.com> wrote:
> Perhaps this will save someone the hours that it
> cost me to figure out how
> to go from a CGI version of PHP (through 4.2) to a
> module version on
> Apache 2 for Win2K.  What I don't understand is why
> the PHP install
> doesn't (1) cover how to install PHP as a module for
> Apache2 and (2)
> discuss the difference between php.exe and
> php-cli.exe (command line
> interface or client? - take your pick).  In the
> discussion below,
> it should be clear that you'll have to substitute
> your own directory
> for where php lives (my root for php is the '4.2'
> directory)
> 
> I've had CGI versions of PHP 4 through several
> releases of Apache and
> the setup for that is really easy (assuming they
> both individually work): 
> 
> 0. Review php.ini (engine = On, et. al) 
> 1. Move php4ts.dll into appropriate windows
> subdirectory (for me it's
> c:\winnt\System32). 
> 
> The remaining 4 items are changes/additions to
> Apache's httpd.conf file
> (note that Apache likes forward slashes (/) instead
> of backslashes (\): 
> 2. Put index.php as the first argument to
> DirectoryIndex if you want
> Apache to automatically pick up index.php files 
> 
> Now add the following 3 lines: 
> 3. AddType application/x-httpd-php .php 
> 4. Action application/x-httpd-php "/php4/php.exe" 
> 5. ScriptAlias /php4/ "c:/winapps/php/4.2/sapi/" 
> 
> 3 is so Apache will know .php files are special. 4
> is so Apache will know
> what special program to run when it realizes it has
> a (.php) special file.
> 5 is so that Apache will know what directory that
> special program
> (php.exe) lives in. 
> 
> To go from the CGI to the Module version should be
> even simpler, right?
> But there is a HUGE gotcha. It's one of those You
> can't get there from
> here syndromes if you are using Apache 2.0.28 (or
> earlier, I presume). I
> needed to upgrade to 2.0.35 so that the required php
> (4.2) provided
> apache2filter.dll file would work with Apache2. 
> 
> So the final steps are as follows: 
> Do steps 0-3 as written above. 
> If you are upgrading, not installing, then back out
> steps 4 and 5 from
> above. 
> 4) Add a line to the httpd.conf file: 
> LoadModule php4_module
> c:/winapps/php/4.2/experimental/apache2filter.dll 
> NOTE that this is not the php4apache.dll file of
> yore in the sapi
> directory (which I presume would work if you were
> doing this with Apache
> 1.3.x)
> 
>      Csaba Gabor
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
> 
>
---------------------------------------------------------------------
> The official User-To-User support forum of the
> Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for
> more info.
> To unsubscribe, e-mail:
> users-unsubscribe@httpd.apache.org
> For additional commands, e-mail:
> users-help@httpd.apache.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org