From: Ben Mansell Date: Mon, 11 Mar 2002 14:34:56 +0000 (+0000) Subject: Instructions for using FastCGI-PHP with Apache X-Git-Tag: help~81 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=889988763f48858f06db1ccb715c6b0938f66d71;p=php Instructions for using FastCGI-PHP with Apache --- diff --git a/sapi/fastcgi/README.Apache b/sapi/fastcgi/README.Apache new file mode 100644 index 0000000000..c7a2172580 --- /dev/null +++ b/sapi/fastcgi/README.Apache @@ -0,0 +1,53 @@ +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/ + + SetHandler fastcgi-script + + +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!