]> granicus.if.org Git - php/commitdiff
Instructions for using FastCGI-PHP with Apache
authorBen Mansell <joosters@php.net>
Mon, 11 Mar 2002 14:34:56 +0000 (14:34 +0000)
committerBen Mansell <joosters@php.net>
Mon, 11 Mar 2002 14:34:56 +0000 (14:34 +0000)
sapi/fastcgi/README.Apache [new file with mode: 0644]

diff --git a/sapi/fastcgi/README.Apache b/sapi/fastcgi/README.Apache
new file mode 100644 (file)
index 0000000..c7a2172
--- /dev/null
@@ -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/
+    <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!