PHP CGI on per-directory basis

PHP CGI on per-directory basis

Posted by: kchrist
Posted on: 2005-09-21 10:43:00

How can I run PHP as CGI on a per-directory basis while keeping it running as an Apache module for the rest of a site?

I normally prefer using mod_php over CGI, so I've never actually had to do this before, but I've now got a situation where I need CGI for one particular application. Converting the entire domain to CGI will break my existing code. The following, in .htaccess in the directory in question, has no effect; phpinfo() still reports that the server API is Apache, not CGI:

RemoveHandler .php
AddHandler cgi-script .php

Thanks.

Re: PHP CGI on per-directory basis

Posted by: scjessey
Posted on: 2005-09-21 11:00:00

In reply to:

How can I run PHP as CGI on a per-directory basis while keeping it running as an Apache module for the rest of a site?


I'm ignorant of such things, but it seems to me that if it isn't possible to do what you want, perhaps you could setup a fully-hosted subdomain with PHP running in CGI mode.

Re: PHP CGI on per-directory basis

Posted by: kchrist
Posted on: 2005-09-21 11:18:00

perhaps you could setup a fully-hosted subdomain with PHP running in CGI mode.

That's my last resort move, but I'd really prefer to not go that route. Before I do that I may just modify the other sections of the site (it's not a big site) so that they run under CGI and deal with the inconveniences. Bleh.

This has proven to be a difficult thing to google for.

Re: PHP CGI on per-directory basis

Posted by: kchrist
Posted on: 2005-09-21 11:45:00

Problem solved. All I need is one line in .htaccess:

AddType php-cgi .php

Re: PHP CGI on per-directory basis

Posted by: scjessey
Posted on: 2005-09-21 12:16:00

In reply to:

Problem solved.


That's all it was? If only all problems could be solved that easily.

Tags: php cgimod phpscript phpphpinfoapache moduleserver apihtaccessdomainrunningask