apache 2.2 (ubuntu) 不允许我通过 .htaccess 设置 php 错误报告?

发布于 2024-09-29 07:15:34 字数 309 浏览 2 评论 0原文

我运行 ubuntu (debian) linux 和 apache 2.2/php 5.2 的服务器有问题,

在 php.ini 中关闭了 display_errors

因为这主要是一个高效服务器,出于开发目的, ,我想要为某些域启用这些错误报告功能。但是当我

设置php_flag display_errors

在测试域的 .htaccess 文件中 时,它根本不起作用:( 所以我必须在 php.ini 中设置 display_errors ,这会影响服务器上的所有网站...如何在本地为一个域设置此设置?

i have a problem with my server which is running ubuntu (debian) linux and apache 2.2/php 5.2

as this is mainly a productive server, display_errors is turned OFF in the php.ini

for development purposes, i want to enable these error reporting stuff for certain domains. but when i set

php_flag display_errors on

in the .htaccess file of the test-domain, it simply wont work :(
so i have to set display_errors in the php.ini which affects ALL websites on the server... how can is set this locally for ONE domain?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-10-06 07:15:34

除非 PHP 作为 Apache 模块运行,否则无法在 .htaccess 文件中提供 PHP 指令。是这样吗?如果是这样,首先确保文件确实正在被读取。您可以做的一个快速测试是故意在 .htaccess 文件中犯一个语法错误:您的网站应该返回 500 错误消息。如果您将 PHP 作为 CGI 运行,则可能为每个用户在某处都有一个自定义 php.ini 文件。

最后但并非最不重要的一点是,您可以针对每个应用程序启用错误报告。只需在顶部添加以下代码:

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

?>

You cannot provide PHP directives in an .htaccess file unless PHP runs as Apache module. Is that the case? If so, first make sure the file is actually being read. A quick test you can do is to make a syntax error on purpose in the .htaccess file: your site should return a 500 error message. If you are running PHP as CGI, you probably have a custom php.ini file somewhere for each user.

Last but not least, you can enable error reporting in a per-application basis. Just add this code on top:

<?php

ini_set('display_errors', 1);
error_reporting(E_ALL);

?>
你的呼吸 2024-10-06 07:15:34

您的虚拟主机中是否启用了 AllowOverride ?如果它设置为“None”,那么 Apache 将完全忽略 .htaccess 文件。

Is AllowOverride enabled in your vhost? If it's set to 'None', then Apache will utterly ignore .htaccess files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文