PHP5 + fastcgi + apache2.2 ... how to for FreeBSD?
nightrecon at hotmail.com
Tue Oct 20 11:14:38 UTC 2009
Marc G. Fournier wrote:
> Is there one somewhere? I'm finding *alot* of Debian ones dealing with
> their whole apget stuff, but would like to find something that "speaks
> normally" :)
Install your choice of flavor of Apache. Me, I'm using the event-mpm for
testing to verify the way to use non-thread safe PHP with a threaded server
Install lang/php5 with various CLI options, as opposed to and instead of
mod_php. This is set of options I used:
# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for php5-5.2.11
Do not try and use MAILHEAD and SUHOSIN together; that combination is
broken. Install the /lang/php5-extensions you require. Currently there seems
to be a problem with extension=sqlite.so, and since I don't use/need it's
commented out of my extensions.ini.
Install www/mod_fcgid from ports. In httpd.conf use:
LoadModule fcgid_module libexec/apache22/mod_fcgid.so
instead of the usual:
LoadModule php5_module libexec/apache22/libphp5.so
Also, further down in httpd.conf:
# This should be changed to whatever you set DocumentRoot to.
# added to enable mod_fcgid
AddHandler fcgid-script .fcgi .php
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
DirectoryIndex index.html index.php
If all went well you should be able to restart Apache and be in business. A
phpinfo(); should execute and provide details. Any problems the quickest way
to check PHP is to just execute php -v at a shell prompt. If it doesn't
segfault it will print out a short descriptive output text.
I believe this is better than the usual script based approach you will
locate on the web. It starts/spawns PHP as a long running process when
Apache starts instead of starting a new CGI each time PHP script is
The mod_fcgid is configurable:
I believe this project was fairly recently folded into the Apache.org
umbrella, but when I began it was separate and standalone. The docs on the
Apache site look like they are for the upcoming 2.3 update to 2.2, and there
may be discrepancies present. I had originally used the docs from the old
site and I don't know if they are even still available.
P.S. - Also, if you need to use Alias they will look like this:
Alias /xcache-admin "/usr/local/share/examples/xcache/admin/"
FCGIWrapper /usr/local/bin/php-cgi .php
Allow from 192.168.10.2
Deny from none
More information about the freebsd-questions