php 本地主机页面不工作本地主机当前无法处理此请求。HTTP 错误 500
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40216761/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The localhost page isn’t working localhost is currently unable to handle this request. HTTP ERROR 500
提问by Mohan
I know that there is some 500 Internal Server Errorwhen is see this page,
我知道看到这个页面时有一些500 内部服务器错误,
The localhost page isn't working localhost is currently unable to handle this request. HTTP ERROR 500
本地主机页面不工作本地主机当前无法处理此请求。HTTP 错误 500
I have already set the variables display_errors: On
and error_reporting : E_ALL
in my php.ini
config file and restarted the server.
我已经设定的变量display_errors: On
,并error_reporting : E_ALL
在我的php.ini
配置文件,重新启动服务器。
I still see the same page and not the actual error message that is causing the Internal Server Error. Why?
我仍然看到相同的页面,而不是导致内部服务器错误的实际错误消息。为什么?
回答by Hossein Ghaem
It maybe solve your problem, check your files access level
它可能会解决您的问题,请检查您的文件访问级别
$ sudo chmod -R 777 /"your files location"
回答by Jaime Montoya
I was using CakePHP and I was seeing this error:
我正在使用 CakePHP,我看到了这个错误:
This page isn't working
localhost is currently unable to handle this request.
HTTP ERROR 500
I went to see the CakePHP Debug Level defined at app\config\core.php:
我去看了在 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);
I chanted the value from 0 to 1:
我把值从 0 到 1 念诵:
Configure::write('debug', 1);
After this change, when trying to reload the page again, I saw the corresponding error:
这个改动后,再次尝试重新加载页面时,看到了相应的错误:
Fatal error: Uncaught Exception: Facebook needs the CURL PHP extension.
Conclusion: The solution in my case to see the errors was to change the CakePHP Debug Level from 0 to 1 in order to show errors and warnings.
结论:在我的情况下,查看错误的解决方案是将 CakePHP 调试级别从 0 更改为 1,以显示错误和警告。
回答by TechnoCat
Here's an answer to a 2-year old question in case it helps anyone else with the same problem.
这是一个 2 年前的问题的答案,以防它可以帮助其他有同样问题的人。
Based upon the information you've provided, a permissions issue on the file (or files) would be one cause of the same 500 Internal Server Error.
根据您提供的信息,文件(或多个文件)的权限问题将是导致 500 内部服务器错误的原因之一。
To check whether this is the problem (if you can't get more detailed information on the error), navigate to the directory in Terminal and run the following command:
要检查这是否是问题(如果您无法获得有关错误的更多详细信息),请导航到终端中的目录并运行以下命令:
ls -la
If you see limited permissions - e.g. -rw-------@
against your file, then that's your problem.
如果您看到有限的权限 - 例如-rw-------@
针对您的文件,那么这就是您的问题。
The solution then is to run chmod 644
on the problem file(s) or chmod 755
on the directories. See this answer - How do I set chmod for a folder and all of its subfolders and files?- for a detailed explanation of how to change permissions.
解决方案是chmod 644
在问题文件或chmod 755
目录上运行。请参阅此答案 -如何为文件夹及其所有子文件夹和文件设置 chmod?- 有关如何更改权限的详细说明。
By way of background, I had precisely the same problem as you did on some files that I had copied over from another Mac via Google Drive, which transfer had stripped most of the permissions from the files.
作为背景,我遇到了与您在我通过 Google Drive 从另一台 Mac 复制的某些文件上遇到的完全相同的问题,这些文件的传输剥夺了文件的大部分权限。
The screenshot below illustrates. The index.php file with the -rw-------@
permissions generates a 500 Internal Server Error, while the index_finstuff.php (precisely the same content!) with -rw-r--r--@
permissions is fine. Changing the permissions on the index.php immediately resolves the problem.
下面的截图说明了。具有-rw-------@
权限的 index.php 文件会生成500 Internal Server Error,而具有-rw-r--r--@
权限的 index_finstuff.php (完全相同的内容!)则很好。更改 index.php 的权限可立即解决问题。
In other words, your PHP code and the server may both be fine. However, the limited read permissions on the file may be forbidding the server from displaying the content, causing the 500 Internal Server Error message to be displayed instead.
换句话说,您的 PHP 代码和服务器可能都没有问题。但是,文件的有限读取权限可能会禁止服务器显示内容,从而导致显示 500 Internal Server Error 消息。
回答by Safdar Ali
If you are using the codeigniter framework and are testing the project on a localhost, open the main Index.php file of your project folder and find this code:
如果您正在使用 codeigniter 框架并在本地主机上测试项目,请打开项目文件夹的主 Index.php 文件并找到以下代码:
define('ENVIRONMENT', 'production');
Change it to
将其更改为
define ('ENVIRONMENT', 'development');
Because same this ENVIRONMENT is in your database.php file under config folder. like this:
因为同样这个环境在 config 文件夹下的 database.php 文件中。像这样:
'db_debug' => (ENVIRONMENT! == 'development')
So the environment should be the same in both places and problem will be solved.
所以两个地方的环境应该是一样的,问题就会解决。
回答by netdev
Such kind of error normally happens when you try using functions like php_info() wrongly.
当您尝试错误地使用 php_info() 等函数时,通常会发生这种错误。
<?php
php_info(); // 500 error
phpinfo(); // Works correctly
?>
PHP errors don't throw 500 request. A close look at your code will be better.
PHP 错误不会抛出 500 请求。仔细看看你的代码会更好。
回答by mdf092
First of all check error log in the path that your webserver indicates. Then maybe the browser is showing friendly error messages, so disable it.
首先检查您的网络服务器指示的路径中的错误日志。那么浏览器可能会显示友好的错误消息,因此请禁用它。
https://superuser.com/questions/202244/show-http-error-details-in-google-chrome
https://superuser.com/questions/202244/show-http-error-details-in-google-chrome
回答by Clarius
So, eventually I did that thing that all developers hate doing. I went and checked the server log files and found a report of a syntax error in line n.
所以,最终我做了所有开发人员都讨厌做的事情。我去检查了服务器日志文件,在第 n 行发现了一个语法错误的报告。
tail -n 20 /var/log/apache2/error.log