当我对以下 PHP 设置使用 .htaccess
时,我在访问该网站时遇到 500 Internal Server Error
。
.htaccess
文件中的代码:
php_flag display_errors off
php_flag log_errors on
.htaccess
文件权限为 644
我知道上面的代码是正确的。但是当它向我显示 500 Internal Server Error
时,我也尝试了不同的代码(很可能是错误的),但没有任何效果。尝试的不同代码是:
php_value display_errors off
php_value log_errors on
和
php_value display_errors 0
php_value log_errors 1
500 Internal Server Error
的原因是什么?
从这个问题的评论中了解到,我发现 .htaccess
上的 PHP 设置不适用于 FastCGI。因此,要更改 PHP 设置,我需要修改 php.ini
或者我需要在 php 代码中进行修改。当我无权修改 php.ini
文件并且我不想单独修改所有 PHP 文件时,有没有其他方法?
最佳答案
就像上面的评论所说:您需要将 php 模块作为 Dynamic Shared Object 运行使其工作,如 Apache PHP Request Hanlding Documentation 中所述
DSO considerations:
libphp provides Apache directives such as php_$value and php_admin_$value. DSO is the only option where these directives will be valid inside .htaccess files or httpd.conf. When these directives are compiled with the concurrent DSO patch, they should be named php4_$value and php5_$value instead.
cgi, fcgi, suphp 都不行。
关于php - 使用 .htaccess 进行 PHP 设置时出现 500 Internal Server Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10928328/