php-src/sapi/fastcgi/README.Apache
2002-03-11 14:34:56 +00:00

54 lines
2.0 KiB
Plaintext

Using FastCGI PHP with Apache
=============================
First of all, you may well ask 'Why?'. After all, Apache already has mod_php.
However, there are advantages to running PHP with FastCGI. Separating the
PHP code from the web server removes 'bloat' from the main server, and should
improve the performance of non-PHP requests. Secondly, having one permanent
PHP process as opposed to one per apache process means that shared resources
like persistent database connections are used more efficiently.
First of all, make sure that the FastCGI module is enabled. You should have
a line in your config like:
LoadModule fastcgi_module /usr/lib/apache/1.3/mod_fastcgi.so
Don't load mod_php, by the way. Make sure it is commented out!
#LoadModule php4_module /usr/lib/apache/1.3/libphp4.so
Now, we'll create a fcgi-bin directory, just like you would do with normal
CGI scripts. You'll need to create a directory somewhere to store your
FastCGI binaries. We'll use /space/fcgi-bin/ for this example. Remember to
copy the FastCGI-PHP binary in there. (named just 'php')
ScriptAlias /fcgi-bin/ /space/fcgi-bin/
<Location /fcgi-bin/>
SetHandler fastcgi-script
</Location>
Next, we need to tell Apache to use the FastCGI binary /fcgi-bin/php to
deliver PHP pages. All that is needed is:
AddType application/x-httpd-php .php
Action application/x-httpd-php /fcgi-bin/php
Now, if you restart Apache, php pages should now be delivered!
Running PHP-FastCGI separately from the webserver
-------------------------------------------------
(Read README.FastCGI for why you might want to do this).
Easy! Add one more configuration line:
FastCgiExternalServer /space/fcgi-bin/php -host localhost:8002
Then, start the PHP off with the following command:
/space/fcgi-bin/php 8002
The number 8002 is the port that PHP will listen on for requests - change this
to anything suitable. And be sure to firewall it out so that external
connections are denied!