php5 running as Apache module gives error 400 (bad request)

848 Views Asked by At

server config: VPS with Centos6.5 + Apache2.2 prefork + Php5.3

My server has now Php running as cgi, and I'd like to add another handler for .php5 files to be executed as Apache module, so part of my php.conf looks like below:

LoadModule php5_module modules/libphp5.so
AddHandler application/x-httpd-php .php5
Action application/x-httpd-php modules/libphp5.so
AddType application/x-httpd-php .php5

Php5_module is loaded:

httpd -M | grep php5 gives php5_module

Then when I try run any script (phpinfo for tests) it gives me 400 bad request.

At the same time .php scripts are running fine as cgi.

Apache error_log isn't helpful, it just says:

[error] [client x.x.x.x] Invalid URI in request GET /phpinfo.php5 HTTP/1.1

I spent hours looking for solution, but found nothing...
What am I missing??

1

There are 1 best solutions below

0
On

I had a similar problem (a 400 Bad Request error), and what fixed it for me was removing the underscore from ServerName... i.e. sub_domain.localhost does not work, but subdomain.localhost does.

This answer solved it for me: https://unix.stackexchange.com/a/404946