[FASTCGI] SetHandler and AddHandler ignored
Rob Saccoccio
robs at fastcgi.com
Tue Oct 7 17:03:37 EDT 2008
> Here's an example config. php-cgi is running in fastcgi mode on
> localhost:9000. I want PHP files (*.php) to be sent to this php-cgi
> daemon and everything else to be served statically by apache. The
> AddHandler statement should do this.
>
> ---BEGIN---
> <VirtualHost *:80>
> ServerName www.example.com
> DocumentRoot /home/user/webs/www.example.com
> AddHandler fastcgi-script .php
> </VirtualHost>
> FastCGIExternalServer /home/user/webs/www.example.com -host 127.0.0.1:9000
> ---END---
>
> What happens is that regardless of the file extention, everything is
> passed to the php daemon running on localhost, php, javascript, images
> and css. Unless you tell it otherwise, PHP serves content as text/html.
> The result is that css and javascript have the wrong content type.
To do what you want, the path in the FastCGIExternalServer directive should
not be a directory. You want something like this (see
http://www.fastcgi.com/docs/faq.html#PHP and the PHP docs):
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /home/user/webs/www.example.com
Action php-fastcgi <php-path>
AddHandler php-fastcgi .php
</VirtualHost>
FastCGIExternalServer <php-path> -host 127.0.0.1:9000
Where <php-path> is someplace outside of your servers' document root or is
inside but is not a directory.
This will define a new handler type called php-fastcgi and associate it with
php-path.
> If you remove the fixups function, which explicitly sets the handler for
> requests to fastcgi-script, everything works as it should.
Funny how that is.
More information about the FastCGI-developers
mailing list