apache 500内部服务器错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1210380/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:59:56  来源:igfitidea点击:

500 Internal Server Error?

phpmysqlsmartyapache

提问by Charlie Epps

Recently, I put my project which is php+smarty+mysql in my httpd server. But I encountered an error that says:

最近,我把我的项目 php+smarty+mysql 放在了我的 httpd 服务器中。但是我遇到了一个错误,它说:

500 Internal Server Error

My OS is archlinux, and the httpd server and php were installed like this:

我的操作系统是archlinux,httpd服务器和php是这样安装的:

sudo pacman -S apache php

If I use a test native php file which contains the following:

如果我使用包含以下内容的测试本机 php 文件:

  <html>
    <head>
    <title>PHP Test Page</title>
    </head>
    <body>
    This is Arch Linux, running PHP.
    <?php
      phpinfo();
    ?>
    </body>
    </html>

it runs correctly. It tells me that the php can work well. But why is my project with smarty not working? Is there any one who has encountered this problem?

它运行正确。它告诉我 php 可以正常工作。但是为什么我的 smarty 项目不起作用?有没有人遇到过这个问题?

回答by Stefano Borini

With the info you provided it's difficult to say.

根据您提供的信息,很难说。

Error 500 happens because you did some error in the code that is supposed to produce the page, or the code generates some unhandled exception. My suggestion is to visit the page that gives you the 500 error, and then try to comment out all your code. See if the issue is still present. If not, uncomment the code until you find the critical part that originates the error. Could be anything, a typo, a file not found, a logical error, anything.

发生错误 500 是因为您在应该生成页面的代码中犯了一些错误,或者代码生成了一些未处理的异常。我的建议是访问出现 500 错误的页面,然后尝试注释掉所有代码。看看问题是否仍然存在。如果不是,请取消注释代码,直到找到导致错误的关键部分。可能是任何东西,打字错误,找不到文件,逻辑错误,任何东西。

Also, check in the webserver logs, if you can read them.

此外,如果您可以阅读网络服务器日志,请检查它们。

回答by chaos

Look in your Apache error log (often found at /var/log/httpd/error_log, though this varies greatly). It will have more information about the server error.

查看您的 Apache 错误日志(通常在 中找到/var/log/httpd/error_log,尽管这差别很大)。它将包含有关服务器错误的更多信息。

回答by AdamDecaf

Check to make sure that any .htaccess files are correct (syntax wise).

检查以确保任何 .htaccess 文件都正确(语法明智)。

回答by jhcaiced

just happened to me and wanted to write down the solution.

刚刚发生在我身上,想写下解决方案。

The configured Smarty cache directory (/var/cache/Smarty) was configured with incorrect permissions, the apache process needs to create files in that directory.

配置的Smarty缓存目录(/var/cache/Smarty)权限配置不正确,apache进程需要在该目录下创建文件。

This is the directory you set with the compile_dir directive.

这是您使用 compile_dir 指令设置的目录。

BTW, the error_log file doesn't show anything with this error, Firebug shows a 500 Internal Server Error.

顺便说一句,error_log 文件没有显示任何有关此错误的内容,Firebug 显示 500 内部服务器错误。

回答by Jose Kj

I was able to get the error details by checking error.log file inside

我能够通过检查里面的 error.log 文件来获取错误详细信息

/var/log/apache2

/var/log/apache2

in ubuntu 16.04

在 Ubuntu 16.04 中