1

I have upgraded from PHP 5.3 to PHP 5.5 (Im running Ubuntu 12.04) By removing the PHP and re-install the 5.5 version and everything worked fine during the installation, now when i open my localhost and try to open any website on my localhost it doesn't execute index.php but it download the index.php as a text file. i restarted Apache2 and saw this posts

nginx localhost is downloading php files in browser, instead of serving them? and localhost doesn't execute php files after update to Maverick/Yosemite OS but it doesn't help.

Help would be appreciated,

Thanks.

Community
  • 1
  • 1
Hamzeh
  • 167
  • 1
  • 4
  • 13
  • Sounds like this is probably worth a look: http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-i-can-see-it-on-source-code-of-page It sounds like Apache either doesn't have a PHP module enabled, or you've not instructed it to process .php files as PHP files. – Brian Sep 03 '14 at 14:56
  • Is there any chance you are using old browser? never tried this, but it is hillarious. https://community.apachefriends.org/f/viewtopic.php?p=129871 – Hendyanto Sep 03 '14 at 14:58
  • How did you uninstall/reinstall PHP? Did you use `apt-get` or any other manual process? – ToBe Sep 03 '14 at 15:09
  • no im not using old browser, i did uninstall using purge and installed using sudo apt-get install php5 – Hamzeh Sep 03 '14 at 15:14

4 Answers4

2

Try using different browser for opening php files. It was not working for me when I opened php files using Chrome. But the same worked in Firefox browser.

Ashutosh Shukla
  • 557
  • 5
  • 9
1

You could try adding this to your conf or htaccess:

AddType application/x-httpd-php .php

or do a proper installation.

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu

Suchit kumar
  • 11,809
  • 3
  • 22
  • 44
0

i think you should take a look at your php module in your apache2. As far as i know php runs as a module in apache so search your httpd.conf for loaded modules and look at your /var/log/apache/error.log or where ever your apache error log

Santa's helper
  • 976
  • 8
  • 21
0

php is not correctly installed on your server otherwise it would have not downloaded the php file. On Ubuntu terminal try

php -v

under your

/etc/apche2/mods-enabled 

see if you have php5.load in the current directory.

Suchit kumar
  • 11,809
  • 3
  • 22
  • 44
Khan Shahrukh
  • 6,109
  • 4
  • 33
  • 43