Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can't get .php files to run on my server. For example, I created a test file entitled "test.php" with the following content (only):

<?php
phpinfo() ;
?> 

When I try to open this or other php files through a web browser, it tries to download them rather than run them. Responses to similar questions suggest that this issue means the server isn't set up to run php. I looked up how to enable php on the server and found that I am supposed to uncomment the line

LoadModule php5_module libexec/apache2/libphp5.so

in the httpd.conf in the etc/apache2 directory. However, when I checked that file, the above line was already uncommented. Is there some other thing I need to change to make php work correctly?

share|improve this question

migrated from stackoverflow.com May 15 '13 at 7:33

This question came from our site for professional and enthusiast programmers.

3  
loading php isn't enough. you need to tell Apache that .php files should be fed through that module, e.g: stackoverflow.com/questions/7856825/… –  Marc B May 14 '13 at 14:34
    
when you open the downloaded file, does it contain the code above? Or does it contain the expected HTML result ? –  nl-x May 14 '13 at 14:34
    
It contains the code above. –  baixiwei May 14 '13 at 19:30
add comment

1 Answer 1

up vote 4 down vote accepted

You also need to add the handler for the PHP extension, so that the scripts are actually handled by the PHP module.

AddHandler php5-script .php
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.