Anthony Gainor Anthony Gainor - 5 months ago 7x
PHP Question

Apache is downloading php files instead of displaying them

OS and server information:

  • CentOS 6.4 (Final)

  • Apache 2.2.15

  • PHP 5.5.1

I previously had php 5.3.x installed but decided to upgrade. I first uninstalled the php 5.3.x and then installed php 5.5.1 but after the installation completed apache did not parse the php files it just downloaded them. I have checked similar questions here in stackoverflow but none of them have helped me so far.

For the record I have the following lines in my httpd.conf and php.conf that should make php work but don't:

AddHandler application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php-source .phps
AddHandler php5-script .php

I would really appreciate any help.
Thank you.


I have these lines in the php.conf

<IfModule !worker.c>
LoadModule php5_module modules/
<IfModule worker.c>
LoadModule php5_module modules/


By removing the

AddType application/x-httpd-php .php5 .php4 .php .php3 .php2 .phtml

apache no longer downloads the file. Now apache is showing the source code, but not all of it just part. I added

AddType text/html .php

but no luck.


The correct AddType for php is application/x-httpd-php

AddType  application/x-httpd-php         .php
AddType  application/x-httpd-php-source  .phps

Also make sure your php module is loaded

LoadModule php5_module        modules/

When you're configuring apache then try to view the page from another browser - I've had days when chrome stubbornly caches the result and it keeps downloading the source code while in another browser it's just fine.