php - 如何修复“Apache2 Debian 默认页面”而不是我的网站
问题描述
我试图用我的树莓派地址读取我的 DS18B20 传感器温度,我在 /var/www/html/index.php 中编写了这段代码
<?php
// Fichier à lire
$file = "/sys/bus/w1/devices/28-80000026ddb1/w1_slave";
// Lecture ligne par ligne
$lines = file($file);
// Recupere la 2nd ligne
$temp = explode(’=’, $lines[1]);
// Formatage de la temperature
$temp = number_format($temp[1]/1000,2, ’.’, ’’);
// On affiche la temperature
echo $temp;echo" degrés Celius";
?>
它出什么问题了?它向我展示了以下内容:
解决方案
您正在查看您的网络服务器的根页面。您的 PHP 代码不在根页面中,您需要浏览到页面 index.php 。
在浏览器栏中点击显示 Apache2 Debian 默认页面的 url,然后是:
/index.php
代替
/index.html
例如:
[ip_address]/index.php
如果 apache 配置文件是默认配置文件,应该不需要其他设置来浏览您的页面。进一步的配置可以将根页面更改为您的。请参阅:如何更改 Apache 中的默认索引页面?
是的,应该安装 PHP 以运行 PHP 代码。
推荐阅读
- hadoop - hadoop v 2如何处理namenode的失败
- hibernate - 如何在休眠中删除子对象之前打破父子关系?
- css - 为什么 _partial 包含在 sass 中
- plugins - 使用 Apache Drill 从 Hive 访问表时出错
- java - Logback 不记录 JUL 精细级别
- grails - 类 [com.docu.MemberInfo] 上的方法在 Grails 应用程序之外使用
- android - 谷歌地图 v2 渲染问题
- matlab - 如何遍历表的一列并将其写入 csv 文件
- python - 芹菜组和链
- android - notificationBuilder.setSound() 到铃声不起作用