localhost页面无法正常工作localhost目前无法处理此请求。 HTTP错误500

时间:2016-10-24 11:00:32

标签: php http-status-code-500

我知道在看到此页面时有一些 500内部服务器错误

  

localhost页面无效localhost当前无法处理此请求。 HTTP ERROR 500

我已在display_errors: On配置文件中设置变量error_reporting : E_ALLphp.ini,然后重新启动服务器。

我仍然看到相同的页面,而不是导致内部服务器错误的实际错误消息。为什么呢?

7 个答案:

答案 0 :(得分:3)

它可以解决您的问题,检查您的文件访问级别

$ sudo chmod -R 777 /"your files location"

答案 1 :(得分:2)

因此,最终我做了所有开发人员都不喜欢做的事情。我去检查了服务器日志文件,并在第n行发现了语法错误的报告。

Force_Authn = true

答案 2 :(得分:1)

我正在使用CakePHP,我看到了这个错误:

This page isn’t working
localhost is currently unable to handle this request.
HTTP ERROR 500

我去看了app \ config \ core.php中定义的CakePHP调试级别:

/**
 * CakePHP Debug Level:
 *
 * Production Mode:
 *  0: No error messages, errors, or warnings shown. Flash messages redirect.
 *
 * Development Mode:
 *  1: Errors and warnings shown, model caches refreshed, flash messages halted.
 *  2: As in 1, but also with full debug messages and SQL output.
 *  3: As in 2, but also with full controller dump.
 *
 * In production mode, flash messages redirect after a time interval.
 * In development mode, you need to click the flash message to continue.
 */
Configure::write('debug', 0);

我将值从0改为1:

Configure::write('debug', 1);

在此更改之后,当我再次尝试重新加载页面时,我看到了相应的错误:

Fatal error: Uncaught Exception: Facebook needs the CURL PHP extension.

结论:在我的案例中看到错误的解决方案是将CakePHP调试级别从0更改为1以显示错误和警告。

答案 3 :(得分:1)

当您尝试错误地使用php_info()等函数时,通常会发生这种错误。

<?php 
     php_info(); // 500 error
     phpinfo(); // Works correctly
?>

PHP错误不会抛出500个请求。仔细查看代码会更好。

答案 4 :(得分:1)

这里是一个2年历史的问题的答案,以防其他有相同问题的人。

根据您提供的信息,一个或多个文件的权限问题将是同样的500 Internal Server Error的原因之一。

要检查是否是问题所在(如果无法获取有关该错误的更多详细信息),请导航至终端中的目录并运行以下命令:

ls -la

如果您看到有限的权限-例如-rw-------@针对您的文件,那就是您的问题。

然后的解决方案是在问题文件上运行chmod 644或在目录上运行chmod 755。有关如何更改权限的详细说明,请参见此答案-How do I set chmod for a folder and all of its subfolders and files?

就背景而言,我遇到了与您通过Google云端硬盘从另一台Mac复制过来的某些文件完全相同的问题,这种转移已剥夺了文件中的大多数权限。

以下屏幕截图说明了这一点。具有-rw-------@权限的index.php文件会产生 500 Internal Server Error ,而具有-rw-r--r--@权限的index_finstuff.php(内容完全相同!)是可以的。更改index.php的权限可立即解决问题。

换句话说,您的PHP代码和服务器可能都很好。但是,对文件的有限读取权限可能会禁止服务器显示内容,从而改为显示500 Internal Server Error消息。

enter image description here

答案 5 :(得分:0)

首先检查网络服务器指示的路径中的错误日志。 然后,浏览器可能会显示友好的错误消息,因此请将其禁用。

https://superuser.com/questions/202244/show-http-error-details-in-google-chrome

答案 6 :(得分:0)

如果您使用codeigniter框架并在localhost上测试项目,请打开项目文件夹的主Index.php文件并找到以下代码:

define('ENVIRONMENT', 'production');

将其更改为

define ('ENVIRONMENT', 'development');

因为相同,该环境位于config文件夹下的database.php文件中。 像这样:

 'db_debug' => (ENVIRONMENT! == 'development')

因此,两个地方的环境应该相同,并且问题将得到解决。

相关问题