PHP文件由浏览器下载,而不是由本地开发服务器(MAMP)处理, [英] PHP files are downloaded by browser instead of processed by local dev server (MAMP)

查看:162
本文介绍了PHP文件由浏览器下载,而不是由本地开发服务器(MAMP)处理,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切都进行得很顺利,直到我将 AddHandler application / x-httpd-php5s .php 添加到本地服务器文档根目录中的.htaccess文件在我工作的网站)。自从我访问 http:// localhost:8888 时,我的浏览器只是下载了index.php,并且没有处理在所有,只是原始代码。现在我从.htaccess文件中删除了该行,但我仍然遇到此问题



我发现如果我添加替代条目到我的主机文件为127.0.0.1新条目行为像'localhost'用于。但如果我添加上面的行到我的.htaccess它敲出新的主机以及。我已尝试重新安装 MAMP ,并清除其缓存和我可以找到的所有临时文件。我通过Apache的httpd.conf文件浏览了所有没有用。



因此,要清楚: http:// localhost:8888 遇到上述问题。如果我添加一个新的条目到我的主机文件为127.0.0.1,说'goomba'和上面的行不在根.htaccess(并从来没有为那个主机/别名/无论如何),然后我可以访问 http:// goomba:8888 就好了。但是如果我添加那行到.htaccess然后我必须添加另一个条目到我的主机文件来解决它,即使我从.htaccess文件删除该行。



我可以使用不同的127.0.0.1别名(主机,什么叫?),但是它让我觉得这仍然是破碎的。



只是为了清楚,我在Mac OS Leopard(但我不是使用内置的Apache安装程序,但MAMP)。

解决方案

您正在应用一个mimetype处理程序应该在哪里(请参阅处理程序文档



请尝试:

 code> AddType application / x-httpd-php5 .php 

编辑:
如您所示,缓存模块已加载,您可以阅读缓存 htcacheclean (清除磁盘缓存)。您还可以暂时使用 CacheDisable 指令。你还可以尝试的另一个事情是重命名您请求的文件(例如index.php - > index.bak),请在浏览器中再次请求该文件(现在应该为404),然后还原,然后重试。 p>

Everything was going great until I added AddHandler application/x-httpd-php5s .php to the .htaccess file in my local server's document root (which I change frequently depending on the site I'm working with). Since I did that when I visit http://localhost:8888 my browser just downloads the index.php and it's not processed at all, just the raw code. Now I removed that line from the .htaccess file but I'm still having this problem.

I've found that if I add an alternative entry to my hosts file for 127.0.0.1 the new entry behaves like 'localhost' used to. But if I add the line above to my .htaccess it knocks out that new host as well. I've tried reinstalling MAMP and clearing its caches and all the temporary files I could find. I surfed through Apache's httpd.conf file all to no avail.

So, to be clear: http://localhost:8888 is experiencing the above problem. If I add a new entry to my hosts file for 127.0.0.1, say 'goomba' and the above line is not in the root .htaccess (and has never been for that host/alias/whatever) then I can access http://goomba:8888 just fine. But if I do add that line to the .htaccess then I have to add yet another entry to my hosts file to get around it even if I remove that line from the the .htaccess file.

I'm fine with using a different 127.0.0.1 alias (host? what is that called?) but it's bugging me that this is still broken.

Just to be clear, I'm on Mac OS Leopard (but I'm not using the built in Apache setup, but MAMP).

解决方案

You are applying a mimetype where a handler should be (see documentation on handlers)

Try this instead:

AddType application/x-httpd-php5 .php

EDIT: As you have indicated caching modules are loaded, you could read up on caching and htcacheclean (to clear the disk cache). You can also temporarily use the CacheDisable directive. One other thing that you could also try is to rename the file that you have requested (e.g. index.php -> index.bak), request the file again in the browser (should now 404), then revert and try again.

这篇关于PHP文件由浏览器下载,而不是由本地开发服务器(MAMP)处理,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆