Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm now so confused with how files should be parsed as PHP with AddHandler in different environments.

local server:

Windows 7 / Apache2.2 / PHP 5.2 (thread safe)

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php52 .php            # does not work
AddHandler application/x-httpd-php .php  # works

And I just upgraded PHP to 5.3 (switched to non thread safe)

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php53 .php            # does not work
AddHandler application/x-httpd-php .php  # does not work <-- works on 5.2
AddHandler php5-script .php              # does not work

# AddHandler... and I'v tried some of others, none of them works

web hosting

CentOS / Apache2.2 / PHP 5.3

AddHandler x-httpd-php .php              # does not work
AddHandler x-httpd-php53 .php            # works
AddHandler application/x-httpd-php .php  # does not work (works prior to 5.2)

My questions:

  1. How come AddHandler application/x-httpd-php .php no longer works on my local server when I updrage PHP to 5.3 non-thread-safe? Are there any other extra work I need to do?

  2. When/where/how should x-httpd-php, application/x-httpd-php, php-script5, and other types of format be used? Are these OS / Apache version / PHP version / PHP type dependent?

edit

OK, I'm gonna answer the first question of my own

Running PHP as an Apache Module

# httpd.conf

PHPIniDir "C:/PHP"
LoadModule php5_module "C:/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php

Running PHP as CGI binary

# httpd.conf

ScriptAlias /PHP/ "C:/PHP/"
Action application/x-httpd-php "/PHP/php-cgi.exe"
AddType application/x-httpd-php .php

<Directory "C:/PHP">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

I'm still waiting for someone to explain the second question.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.