Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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):

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/

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 May 15 '13 at 7:33

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

loading php isn't enough. you need to tell Apache that .php files should be fed through that module, e.g:… – 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
up vote 5 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
For those using php7. File httpd.conf in your <IfModule mime_module> add this line -> AddHandler php7-script .php – B4NZ41 Mar 31 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .