OS and server information:
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.
EDIT:
I have these lines in the php.conf
<IfModule !worker.c> LoadModule php5_module modules/libphp5.so </IfModule> <IfModule worker.c> LoadModule php5_module modules/libphp5-zts.so </IfModule>
EDIT:
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.
This is normally due to an improper handler code. In the . htaccess file, you will want to ensure the handler code matches your version of php. If it does not, the php files may try to download instead of process.
First of all, you need to make sure that your server is up-to-date. If your server is not updated then there are chances that it may be a reason for the downloading files instead of opening in browser error. To fix this issue, you'll need to check whether your hosting provider has an update available or not.
You've written your first PHP program, but when you go to run it, all you see in your browser is the code—the program doesn't actually run. When this happens, the most common cause is that you are trying to run PHP somewhere that doesn't support PHP.
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/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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With