【发布时间】:2014-11-01 21:47:12
【问题描述】:
我无法在如下所示的 html 页面上运行 php 脚本:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Directory Contents</title>
<link rel="stylesheet" href="stylesheets/displayStylesheet.css">
<script src="javascripts/sorttable.js"></script>
</head>
<body>
<div id="container">
<h1>Directory Contents</h1>
<table class="sortable">
<thead>
<tr>
<th>Filename</th>
<th>Type</th>
<th>Size <small>(bytes)</small></th>
<th>Date Modified</th>
</tr>
</thead>
<tbody>
<?php require ($_SERVER['DOCUMENT_ROOT'].'/php/displayDirectory.php5'); ?>
</tbody>
</table>
</div>
</body>
</html>
这是我的 .htaccess 文件:
AddType application/x-httpd-php5 .php5 AddType application/x-httpd-php5 .phps
在我的 apache.conf 中我添加了:
LoadModule php5_module modules/mod_php55.so
但是,在重新启动 apache 时,警告显示它已经加载。
我还检查了是否安装了 php,它是版本 5。此时 index.html 加载 displayDirectory.html 但其中的 php 代码没有被处理。
我错过了什么吗?
【问题讨论】:
-
PHP 代码存在语法错误
-
您的 .htaccess 文件是否正常工作?一个简单的检查方法是在文件中放置一个故意的语法错误,看看你的服务器是否给你一个错误。如果是这样,它正在工作。如果没有,那么 htaccess 没有被读取。