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 working on a client site that is hosted on someone's DIY Debian Linux server [Apache/1.3.33 (Debian GNU/Linux)], and I'm trying to install a script that requires PHP5. By default, the server parses .php files with PHP 4.3.10-22, which is configured at /etc/php4/apache/php.ini, according to phpinfo(). On the server I can see a config directory for PHP5 adjacent to the PHP4 directory: /etc/php5.0/apache2/php.ini.

I have tried multiple methods to enable PHP5 for the document root where the site's files are hosted, including all available methods mentioned here. By far, the most common suggestion I've found is to add one or both of the following lines to the site's .htaccess file:

AddHandler application/x-httpd-php5 .php
AddType application/x-httpd-php5 .php

Trouble is, when either or both of those lines are present, the site forces my browser to download any .php files requested, without parsing the PHP at all. All of the other methods mentioned in the above article cause a 500 Internal Server Error. There is no hosting control panel I can access in a browser to enable PHP5 for the site, but I do have shell access.

When I asked the server administrator about this issue, he encouraged me to search for the answer on Google.

Where could I begin to troubleshoot this issue? Are there ways to test or verify the server's specific PHP5 installation and configuration, using the command line or some other method? Do you have other suggestions to enable PHP5?

share|improve this question
    
Originally posted on stackoverflow, but flagged to be posted here: stackoverflow.com/questions/2887196/… –  John Stephens May 22 '10 at 15:13
1  
Creating a duplicate question is not the way to handle this. –  Ignacio Vazquez-Abrams May 22 '10 at 15:14
    
One response suggested I move the question here. It's no longer a duplicate: I've deleted the original. –  John Stephens May 22 '10 at 15:32

1 Answer 1

Both the PHP4 and PHP5 modules have to be loaded as well as have handlers specified. It sounds like the PHP5 module isn't loaded. If both modules are loaded, the MIME type isn't specified properly.

share|improve this answer
    
Thank you. Here's what I found: cgi.load, php5.0.conf, php5.0.load, userdir.conf, and userdir.load, are listed under "/etc/apache2/mods-enabled/". I note that PHP5's .ini file is nested under a directory called "apache2", while PHP4's is in a directory called "apache", and according the phpinfo(), the version of Apache running is "Apache/1.3.33". Does PHP5 require Apache 2 to load properly? –  John Stephens May 22 '10 at 18:54
    
PHP5 does not require Apache2 but if you're using distribution packages there may be some assumptions in the configuration files. –  Warner May 22 '10 at 19:29
    
I also found "/etc/apache/modules.conf" file that includes a line loading php4_module from "/usr/lib/apache/1.3/libphp4.so", but there's no reference to PHP5. –  John Stephens May 22 '10 at 19:30
    
So add lines for PHP5 too. =) –  Warner May 22 '10 at 20:12
    
The file says "Autogenerated file - do not edit!" and includes the following update command: "/usr/sbin/apache-modconf apache"-- but that command requires superuser privileges. Also, I don't see any files in the "/usr/lib/apache/" directory that mention PHP5. What is the name of the module I need to enable? –  John Stephens May 22 '10 at 22:01

Your Answer

 
discard

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