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?

link|improve this question

31% accept rate
If not, what is the best process to uninstall PHP and reinstall, especially if there are other services preinstalled that may depend on PHP. (The server is not yet live, still configuring it.) – inac Jun 21 '10 at 4:03
feedback

2 Answers

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.

link|improve this answer
How do you enable mod_php on a stock CentOS install? – inac Jun 21 '10 at 4:35
Installing the php package will install mod_php and pull in the httpd package as well. The default configurations for the two, when installed together, enables mod_php. – Ignacio Vazquez-Abrams Jun 21 '10 at 4:53
PHP has already been installed - any advice on the best process to uninstall PHP and reinstall, especially if there are other services preinstalled that may depend on PHP. (The server is not yet live, still configuring it.) – inac Jun 21 '10 at 10:53
feedback

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.

link|improve this answer
PHP has already been installed - any advice on the best process to uninstall PHP and reinstall, especially if there are other services preinstalled that may depend on PHP. (The server is not yet live, still configuring it.) – inac Jun 21 '10 at 11:03
These steps (6, 7, 8 ...) address the part of the question where you asked "change PHP into an apache module". Are you focusing on only uninstall/reinstall now? – Beel Jun 21 '10 at 12:36
I'm trying to work this with the existing install, but after going through 6,7,8 (in 8, skipping "mod_rewrite may be used To allow any arbitrary .php file to be displayed as syntax-highlighted source code, without having to rename or copy it to a .phps file"), my .php / .phps files become interpreted as file downloads, rather than being displayed in the browser. – inac Jun 21 '10 at 23:19
LoadModule auth_passthrough_module modules/mod_auth_passthrough.so<br /> LoadModule bwlimited_module modules/mod_bwlimited.so<br /> LoadModule frontpage_module modules/mod_frontpage.so<br /> LoadModule php5_module modules/libphp5.so << added in step 7 – inac Jun 21 '10 at 23:20
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.