无法从 nginx 服务器连接到 php 文件
Can't connect to a php file from nginx server
我在我的 rpi2 上设置了一个 nginx 服务器,它工作正常并且链接到我的网站。我也设置了 php5-fpm,我的 index.php 文件很简单,只是为了测试一下。
<?php phpinfo(); ?>
前往 website.com 有效,它显示 php 信息屏幕。转到网站。com/index。php 以及 webstie。com/index。html,它显示默认的 "Welcome to nginx!" 屏幕。
但是,我正在开发一个帐户系统并设置了这个简单的页面并将其放在包含我的索引文件的 www 文件夹中并将其命名为 login.php:
<?php
session_start();
?>
<html>
<head>
<meta http=equiv="Content Type" content="text/html; charset=utf-8" />
<title>Member System - Login</title>
</head>
<body>
<?php
$form="<form action='./login.php' method='post'></form>";
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user= $_POST['user'];
$password = $_POST['password'];
if ($user) {
if($password){
echo "$user - $password <hr /> $form";
} else echo "You must enter your password. $form";
} else echo "You must enter your username. $form";
} else {
echo $form;
}
?>
</body>
</html>
但是,每当我在单独的 PC 上访问网站。com/login.php 时,Chrome 显示 "The website.com page isn't working. website.com is currently unable to handle this request." HTTP 错误 500,这是一个内部服务器错误。
我在 www 文件夹里 运行
sudo cp index.php test.php
然后重新加载nginx。转到网站。com/test.php 有效,所以我假设错误出在我的 login.php 文件中,但我一直无法弄清楚。
我的代码有什么问题?感谢任何帮助
如果显示的示例是 login.php 的内容,则说明您的代码有误
$form="<form action='./login.php' method='post'></form>";
<table>
将不起作用,因为 <table>
挂在字符串外的它自己的行上,删除 ";
可能会解决问题
我在我的 rpi2 上设置了一个 nginx 服务器,它工作正常并且链接到我的网站。我也设置了 php5-fpm,我的 index.php 文件很简单,只是为了测试一下。
<?php phpinfo(); ?>
前往 website.com 有效,它显示 php 信息屏幕。转到网站。com/index。php 以及 webstie。com/index。html,它显示默认的 "Welcome to nginx!" 屏幕。
但是,我正在开发一个帐户系统并设置了这个简单的页面并将其放在包含我的索引文件的 www 文件夹中并将其命名为 login.php:
<?php
session_start();
?>
<html>
<head>
<meta http=equiv="Content Type" content="text/html; charset=utf-8" />
<title>Member System - Login</title>
</head>
<body>
<?php
$form="<form action='./login.php' method='post'></form>";
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login' /></td>
</tr>
</table>
</form>";
if ($_POST['loginbtn']){
$user= $_POST['user'];
$password = $_POST['password'];
if ($user) {
if($password){
echo "$user - $password <hr /> $form";
} else echo "You must enter your password. $form";
} else echo "You must enter your username. $form";
} else {
echo $form;
}
?>
</body>
</html>
但是,每当我在单独的 PC 上访问网站。com/login.php 时,Chrome 显示 "The website.com page isn't working. website.com is currently unable to handle this request." HTTP 错误 500,这是一个内部服务器错误。
我在 www 文件夹里 运行
sudo cp index.php test.php
然后重新加载nginx。转到网站。com/test.php 有效,所以我假设错误出在我的 login.php 文件中,但我一直无法弄清楚。
我的代码有什么问题?感谢任何帮助
如果显示的示例是 login.php 的内容,则说明您的代码有误
$form="<form action='./login.php' method='post'></form>";
<table>
将不起作用,因为 <table>
挂在字符串外的它自己的行上,删除 ";
可能会解决问题