本地主机页面不起作用本地主机当前无法处理此请求。 HTTP错误500

问题描述 投票:8回答:6

我知道在看到此页面时出现某些500内部服务器错误

[localhost]页面不起作用,localhost当前无法处理此请求。 HTTP错误500

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

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

php http-status-code-500
6个回答
5
投票

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

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

3
投票

这里是一个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内部服务器错误,而具有-rw-r--r--@权限的index_finstuff.php(内容完全相同!)就可以了。更改index.php的权限可立即解决问题。

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

enter image description here


2
投票

我使用的是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,以显示错误和警告。


1
投票

当您尝试错误地使用类似php_info()的函数时,通常会发生此类错误。

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

PHP错误不会引发500个请求。仔细查看您的代码会更好。


0
投票

首先检查您的Web服务器指示的路径中的错误日志。然后,也许浏览器显示友好的错误消息,请禁用它。

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


0
投票

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

define('ENVIRONMENT', 'production');

更改为

define ('ENVIRONMENT', 'development');

由于此环境同样位于您的database.php文件中的config文件夹下。像这样:

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

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

© www.soinside.com 2019 - 2024. All rights reserved.