无法让 php 文件在浏览器中运行?Ubuntu

无法让 php 文件在浏览器中运行?Ubuntu

我正在尝试运行一个从 MySQL 数据库读取信息的 .php 文件。我已经安装了 php5:

developer@alchemy:~/dev$ php --version
PHP 5.3.10-1ubuntu3.13 with Suhosin-Patch (cli) (built: Jul  7 2014 18:52:09) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

我已经安装并运行 apache2:

developer@alchemy:~/dev$ sudo netstat -ntlup
[sudo] password for developer: 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN        1224/mysqld     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      30018/apache2   

这是 Display.php 文件:

<!DOCTYPE html>
<html>
<head><title>Display udp packet</title>
<style type="text/css">
body {
  background-color: #29C;
}
.display-box {
  border: solid 2px #FFF;
  padding: 10px;
  border-radius: 4px;
}

</style>
</head>

<body>
<?php
$dbcnx = mysqli_connect("localhost", "root", '', "udp");
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
<div align="center">
<p class="display-box">Data:
<?php
  #Select Database
  mysql_select_db("data")

  #Collect data from table "data"
  $result = mysqli_query($dbcnx, "SELECT * FROM data");

  #temporary test display
  echo "<p>$data</p>";

 # while($row = mysqli_fetch_array($result)) {    
 #   echo $row['packetdata'] . " " . $row['date'];
 # }

  #mysql_close($dbcnx);
?>
</div>
</body>

</html>

该文件位于路径 /home/developer/dev/Display.php 中,我在网上找到的显示 php 文件的方法是在搜索栏中输入:

http://localhost/where/file/is/saved/Display.php

然而,这返回了一个

“未找到

“此服务器上未找到所请求的 URL /display.php。”消息。我该如何运行 php 文件?我遗漏了什么吗?

相关内容