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 moved a website from another server to mine and there is a PHP file with .ph extension. On other server it worked fine, but not on the new one. It just tries to download the file in question, instead of sending it through PHP parser.

Obviously it's about file handlers, so I need to add .ph extension to be handled as .php file. I thought this was trivial, but still couldn't do it :) It has somehow changed in Apache2 and I can't seem to figure it out.

I've tried to set the handler in mime.conf and in /etc/mime.types. Nothing so far.

Due to the app complexity, I wish I wouldn't have to change the extension of the file. Could someone point me to the right direction? This shouldn't be this hard :)

I'm running Apache 2.2.17 and PHP 5.3.5 on Ubuntu 11.04.

share|improve this question
add comment

2 Answers

try this after modifying mime configuration

service apache2 restart

or edit your httpd.conf

Updated & tested:

AddHandler type-map var
AddHandler php5-script .ph
AddType text/html .php
share|improve this answer
    
Nope. At least adding AddType text/html .ph makes it stop to try to download the file in question, but no; it still won't parse it. –  budwiser Feb 15 '12 at 7:22
    
already added into my test server and restart apache. it parse .ph and content php echo "HELLO WORLD" into HELLO WORLD only. –  apis17 Feb 15 '12 at 7:27
    
i'm not add any MIME type. can you remove mime type and try again? –  apis17 Feb 15 '12 at 7:27
    
Got it. But thanks for your help. –  budwiser Feb 15 '12 at 7:42
add comment
up vote 0 down vote accepted

The problem seemed to be that I had this definition in my /etc/apache2/mods-available/php5.conf file:

<FilesMatch "\.ph(p3?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

The regexp pattern expected either p3 or tml ending to .ph - prefix.

The easiest fix was just to add:

<FilesMatch "\.ph$">
    SetHandler application/x-httpd-php
</FilesMatch>

into the file. Works like a charm now.

share|improve this answer
add comment

Your Answer

 
discard

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

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