.php files not working with AddHandler – Apache 2.4

apache-2.4php5

I am having an issue with Apache 2.4 configuration with PHP5. I have got this:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>

It works for both .html and .htm files (i.e. backButton.cgi runs) but not for .php. I have tried everything I can find on the topic including just having .php (i.e AddHandler backButton .php).

If there is any extra information required please ask.

Best Answer

You have this set:

Action add-footer /script.pl
AddHandler add-footer .html .htm .php

Which seems odd to me. What is add-footer? What is script.pl? That seems to be an example from the Apache site that would cause requests for files with the html extension to trigger the launch of the footer.pl CGI script. Why would you need that?

Seems like that should be:

AddHandler php5-script php

So your whole Directory directive should be:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi .pl
  AddHandler php5-script php
</Directory>

EDIT: Since the original poster does want the add-footer functionality—now called backButton—it seems that this configuration would be the best way to handle; combine what I am doing above with with the original poster posted to begin with:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi
  AddHandler php5-script .php

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>

ANOTHER EDIT: Seems like there was a typo the first time with me setting php instead of .php for AddHandler php5-script .php. But also, try this instead using application/x-httpd-php5 instead of php5-script:

<Directory / >
  Options +ExecCGI
  AddHandler cgi-script .cgi
  AddHandler application/x-httpd-php5 .php

  Action backButton /backButton.cgi
  AddHandler backButton .html .htm .php
</Directory>