PHP, WHM, and several other services are already installed on a CentOS x64 server I am trying to migrate data to. Many of my existing PHP scripts are dependent on PHP's apache_request_headers() function, which the current server's PHP configuration does not support. Apparently, compiling PHP as an Apache module is one solution, but are there other ways to enable this (without uninstalling PHP, reinstalling, etc., and all dependent services), perhaps as easy as modifying php.ini, somehow?
The Apache functions are only available if running the httpd SAPI, also known as mod_php.
The stock CentOS PHP packages make mod_php available, so they are enough to allow them. If you need a newer version than the stock packages then you will need to find newer packages somewhere, or you will need to build PHP or the PHP packages yourself with the proper SAPI.
Here is documentation on setting up PHP to run under Apache 2. The site also contains info for Apache 1. http://www.php.net/manual/en/install.unix.apache2.php
The most directly relevant items are 6, 7, and 8
6.Setup your php.ini
7.Edit your httpd.conf to load the PHP module.
8.Tell Apache to parse certain extensions as PHP.
If you're running PHP as CGI/FastCGI then you don't get the
apache_request_headers()
(also known asgetallheaders()
) function.However...
As of 5.4.0, PHP includes a version of this function which works in FastCGI.
For previous versions of PHP you can roll your own. Though this approach loses case sensitivity for header names (CGI/FastCGI capitalize all header names) it's generally good enough for 99.9% of possible purposes.
This is my code for doing so, written long ago and published under LGPLv3: