【发布时间】:2012-01-20 20:15:25
【问题描述】:
我现在在网络解决方案小型 unix 服务器上运行一个站点。这是我客户的选择,不是我的。让我们假设现在改变不是一种选择。
我收到大量 500 次内部服务器错误事件。它们是零星的,但显然发生得太频繁了。哪些页面触发了错误并没有太大的一致性,但它发生的太多了,非常令人沮丧。
在设置服务器和搞乱设置方面......好吧,我对这类事情没有太多经验......通常我所做的工作。
好的,我已启用错误,这是我收到的内容:
[Wed Dec 14 23:56:04 2011][error] [client *] 脚本头提前结束:index.php,引用:mysite.com/administration/
这是我的页面代码:
<?php
//start the session
session_start();
if (isset($_SESSION['user_id'])) {
header('Location:main.php');
}
else{
include("../includes/configure.php");
$menu_bar = false;
$login_form = true;
$status = 'Please Log in';
$header_message = 'Welcome to the mysite Administartion System';
if (isset($_POST['submit'])) {
include("utilities/login.php");
}
if (isset($_GET['redirect'])){
switch ($_GET['redirect']) {
case 'denied':
$header_message = 'The page you have tried to access is forbidden, please login';
break;
case 'logout':
$header_message = 'You have logged out successfully';
}
}
}
include($layout_includes_dir."header.php");
include($admin_layout_dir."administration_layout.php");
include($layout_includes_dir."footer.php");
?>
这里是实用程序/login.php
if (!isset($_SESSION['user_id'])) {
$username = mysqli_real_escape_string($dbc, trim($_POST['username']));
$password = mysqli_real_escape_string($dbc, trim($_POST['password']));
if (!empty($username) && !empty($password)) {
// Look up the username and password in the database
$query = "SELECT id, username, password FROM user WHERE username = '$username' AND password = SHA('$password')";
$data = mysqli_query($dbc, $query);
if (mysqli_num_rows($data) == 1) {
// The log-in is OK so set the user ID and username session vars (and cookies), and redirect to the home page
$row = mysqli_fetch_array($data);
$_SESSION['user_id'] = $row['id'];
$_SESSION['username'] = $row['username'];
header('Location:main.php');
}
else{
// The username/password are incorrect so set an error message
$message = 'Sorry, you must enter a valid username and password to log in.';
}
}
else {
// The username/password weren't entered so set an error message
$message = 'Please enter a username or password to login.';
}
}
【问题讨论】:
-
查看
error.log或系统日志以找到更具体的提示。其他一切都只是猜测。另外你真的有一个原始的 CGI 版本的 PHP 运行吗?作为 .cgi 文件之类的脚本? -
错误 500 通常意味着您的 PHP 应用程序出现错误,如果您使用 php 文件内容和日志文件编辑问题,也许我们可以尝试帮助诊断原因问题
-
好的,发现错误信息并添加到原始问题中!
-
这可能与您的问题无关,但您应该知道发送
Location标头不会结束脚本。也就是说,仍然会向客户端发送页面(例如,最后的所有includes),但大多数人不会看到它,因为浏览器透明地遵循重定向。