Ex-Ex
Ex-Ex

Reputation: 176

localhost downloading the *.php files instead of viewing it

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.

Upvotes: 2

Views: 12218

Answers (5)

my_test_account
my_test_account

Reputation: 1

I have solved with PHPSTORM by; Settings => Editor => File Types find the PHP from the "Recognized File Types" list? and click on + plus sign and re add the *.php to the the list and that's it. Hope it works, good luck 🤞

Upvotes: 0

Ashutosh Shukla
Ashutosh Shukla

Reputation: 555

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.

Upvotes: 1

Suchit kumar
Suchit kumar

Reputation: 11859

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

Upvotes: 1

Khan Shahrukh
Khan Shahrukh

Reputation: 6361

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.

Upvotes: 0

Santa's helper
Santa's helper

Reputation: 996

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

Upvotes: 0

Related Questions