使用.htaccess进行PHP设置时出现500内部服务器错误 [英] 500 Internal Server Error when using .htaccess for PHP Settings

查看:88
本文介绍了使用.htaccess进行PHP设置时出现500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我对以下PHP设置使用 .htaccess 时,在访问时出现 500 Internal Server Error

When I am using .htaccess for the following PHP settings, I am getting 500 Internal Server Error while accessing the website.

.htaccess 文件中的代码:

php_flag display_errors off
php_flag log_errors on

.htaccess 文件的文件权限为644

The file permission for the .htaccess file is 644

我知道上面的代码是正确的。但是,当它显示 500 Internal Server Error 时,我也尝试了其他代码(很可能是错误的),但没有任何效果。尝试使用的不同代码是:

I know that code above is correct. But when it showed me 500 Internal Server Error, I tried different code (most probably wrong) too, but nothing worked. The different code tried are:

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 不适用于FastCGI。因此,要更改PHP设置,我需要修改 php.ini ,或者需要在php代码中进行修改。当我无权修改 php.ini 文件并且我不想单独修改所有PHP文件时,还有其他替代方法吗?

After learning from the comments on this question, I found that PHP settings on .htaccess does not work with FastCGI. So, to change PHP settings, I need to modify the php.ini or I need to do it in the php code. Is there any alternate way, when I don't have access to modify php.ini file and I don't want to individually modify all the PHP files?

推荐答案

就像上面的评论所述:您需要以动态共享对象使其生效,如 Apache PHP请求处理文档

Like the comments above said: you need to run your php module as Dynamic Shared Object to make it work, as described in the Apache PHP Request Hanlding Documentation


DSO注意事项:

DSO considerations:

libphp提供Apache指令,例如php_ $ value和php_admin_ $ value。 DSO是这些指令在.htaccess文件或httpd.conf中有效的唯一选项。当这些指令与并发DSO补丁一起编译时,应将它们分别命名为php4_ $ value和php5_ $ value。

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,请不要使用。

cgi, fcgi, suphp it will not work.

这篇关于使用.htaccess进行PHP设置时出现500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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