Apache is downloading php files instead of displaying them
The correct AddType for php is application/x-httpd-php
AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
Also make sure your php module is loaded
LoadModule php5_module modules/mod_php55.so
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.
I came across this issue today and none of the solutions described worked for me. So here is another possible cause:
If you have something like
AddHandler x-mapp-php6 .php3 .php4 .php .phtml
in a .htaccess
file of your web content folder, it can cause your PHP scripts to stop working. In my case the server did not know the x-mapp-php6
type, since that .htaccess
file was something I imported from a different web host when I transferred the website content.
Just removing the AddHandler
line from the .htaccess
file solved it for me.
After struggling a lot I finally solved the problem.
If you are prompted to download a .php
file instead of executing it, then here is the perfect solution: I assume that you have installed PHP5 already and still getting this error.
$ sudo su$ a2enmod php5
This is it.
But If you are still getting the error :
Config file php5.conf not properly enabled: /etc/apache2/mods-enabled/php5.conf is a real file, not touching it
then do the following:
Turns out files shouldn't be stored in mods-enabled
, but should rather be stored in mods-available
. A symlink should then be created in mods-enabled pointing to the file stored in mods-available.
First remove the original:
$ mv /etc/apache2/mods-enabled/php5.conf /etc/apache2/mods-available/
Then create the symbolic link:
$ ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf
I hope your problem is solved.