PHP5 + fastcgi + apache2.2 ... how to for FreeBSD?
Michael Powell
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" :)
>
[snip]
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
is FastCGI.
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
_OPTIONS_READ=php5-5.2.11
WITH_CLI=true
WITH_CGI=true
WITHOUT_APACHE=true
WITHOUT_DEBUG=true
WITH_SUHOSIN=true
WITH_MULTIBYTE=true
WITHOUT_IPV6=true
WITHOUT_MAILHEAD=true
WITH_REDIRECT=true
WITH_DISCARD=true
WITH_FASTCGI=true
WITH_PATHINFO=true
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.
#
<Directory "/usr/local/www/apache22/data">
[...]
</Directory>
# added to enable mod_fcgid
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi .php
SocketPath /var/run/fcgidsock/
IPCConnectTimeout 10
IPCCommTimeout 20
OutputBufferSize 0
</IfModule>
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
[...]
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
executed.
The mod_fcgid is configurable:
http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
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.
-Mike
P.S. - Also, if you need to use Alias they will look like this:
Alias /xcache-admin "/usr/local/share/examples/xcache/admin/"
<Directory "/usr/local/share/examples/xcache/admin/">
#SetHandler None
FCGIWrapper /usr/local/bin/php-cgi .php
Options ExecCGI
Order allow,deny
Allow from 192.168.10.2
Deny from none
</Directory>
More information about the freebsd-questions
mailing list