Php file being downloaded instead of viewed






















Active Oldest Votes. You might have only have the cli version of PHP installed currently try sudo apt-get install php5 and restart apache sudo apache2ctl restart. You can also check the PHP module is loaded into apache by doing sudo apache2ctl -M Which if the module is loaded then it should show something like Loaded Modules Syntax OK.

Improve this answer. Mark Davidson Mark Davidson 4 4 silver badges 11 11 bronze badges. Add a comment. Thanks a lot. It would look something like this: Use for PHP 5. Do NOT set it to On as it prevents. I did what it says and restarted apache and the problem had gone.

Adrian Heine 4 4 silver badges 22 22 bronze badges. Agree With Comment Policy. Are you sure this code is legit, I mean when we go to WordPress. Yes the code is legit. When you have a fresh copy of WordPress the. But after you install it, you will find that some more lines are automatically added by WordPress for Proper functioning.

It will download a file called index. This happens due to compressing of files by some caching plugin or server. I hope this helps you, If your problem is solved by this method.

Kindly let us know in the comments section. I had faced this problem many time but at the end, it solves automatically, but this it is happening again and again. For eg. It only takes a minute to sign up. Connect and share knowledge within a single location that is structured and easy to search. Sometimes, when I do something wrong, instead of getting an error, the script I'm testing is offered for download.

Why is that and how can it be fixed? The server does not recognize the script as something to execute locally, and as such it offers it as a file instead. These lines should be present in your Apache config. Note that the path may need to be changed for the. I would agree with Avery, that's the usual cause. However, you specifically say it's only sometimes.

Any chance you are changing the content type header? Also note that if you have a. For example, if you got a copy of the site files from another server, your htaccess file could have a line like:.

The relevant part being Show 4 more comments. Active Oldest Votes. Jack M. Joy, tried your suggestion but it didn't worked. For php7. Show 10 more comments. I think the restart and incognito mode helped me. Thank a ton for the noobness we can do. Thanks a lot. This made it for me, also after hours trying a lot of other solutions suggested.

It was strange to me that my site worked on IE and chrome while in mozilla it downloded the site intead of executing it. It was mozilla's cache fault. You saved my time bro. Show 1 more comment. If you're using PHP 7. AndrewFox- my filename is php7. M Arfan M Arfan 3, 4 4 gold badges 24 24 silver badges 43 43 bronze badges. I tried this didn't work for me, I'm using ubuntu Add a comment. So here are my 2 cents, nginx is a web server and not an application server and thus, it can only serve static pages.

This is where common gateway interface CGI comes in. It's a piece of software that manages this communication. Nice explainer.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You can type! Your config file looks proper. I have this issue too… Same config… My droplet is www. Referenced it from a working server, then ran a quick search for additional info. Kamal, thank you for your answer. I keep downloading the index.



0コメント

  • 1000 / 1000