简体   繁体   中英

My .php files not running on WAMP Server, it is trying to save the file instead

I have just cloned a project, so it works perfectly fine when i load it eg: "localhost/example/contact.html", but when i click to homepage which the endpoint is "localhost/example/index.php" it asks me to save the file like that: Asking to save the php file

I have checked everything in files such as php.ini, httpd.conf but still cant find a solution, I also reinstalled wamp 2 times.

Also the php error log gives me this error: The file C:/WINDOWS/system32/drivers/etc/hosts does not exists

Any help would be appreciated!

You need to load and enable mod_php or set up php-fpm. Afaik Wamp uses mod_php which is simpler. The reason your web browser asks you to download the php files is because you have not told the web server to treat.php files differently that.txt files.

There are plenty of resources on the interwebs about setting up php and apache:

Given that you are using Wamp, which should work out of the box, I'd say reinstall one more time and run the installer as an admin. If the issue about the etc/hosts file persists, you can create the file yourself .

However, I don't think the hosts file is necessary to run wamp or to render / run.php files.


PS: Your question is not about programming or code, so it's going to be closed because it fits better on the superuser website. Welcome to SO!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM