阿帕奇2 Ubuntu的服务器无法解析HTML文件中的PHP code [英] Apache 2 server on ubuntu can't parse php code inside html file
问题描述
我安装的Apache2,PHP5和在Ubuntu 13.04的PHP5 Apache模块。
PHP是工作的PHP文件,但HTML文件里的PHP $ C $行C不执行。
谷歌搜索,我发现必须添加的AddHandler ...
和将AddType ...
行httpd.conf中,但安装的版本没有这个文件,或至少不能在的/ etc / apache2的/
code例如:
< HTML和GT;
< HEAD>< /头>
<身体GT;
< PHP
的phpinfo();
?>
< /身体GT;
< / HTML>
得到它的工作。我的Apache的版本没有的httpd.conf,而不是具有 php5.conf
在的/ etc / apache2的/启用MODS-/
编辑这个文件,发现这一点:
< FilesMatch&GT+ \\ pH值(P [345] | |牛逼TML?)$。
SetHandler应用程序/ X的httpd - PHP
< / FilesMatch>
&所述; FilesMatch+ \\ PHPS $>
SetHandler应用A
....
....
添加行:
< FilesMatch&GT+ \\ $ HTML。
SetHandler应用程序/ X的httpd - PHP
< / FilesMatch>
现在PHP解析HTML文件和<?PHP ......方式>
code ++工程
I installed apache2, php5 and the php5 apache module on Ubuntu 13.04.
Php is working on .php files but lines of php code inside html files do not execute.
Googling I found that must add AddHandler...
and AddType...
lines to httpd.conf but the version installed doesn't have this file or at least can't find it in /etc/apache2/
code example:
<html>
<head></head>
<body>
<?php
phpinfo();
?>
</body>
</html>
Got it to work. my version of apache doesn't have httpd.conf, instead has php5.conf
in /etc/apache2/mods-enabled/
editing that file, found this:
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
SetHandler applicatio
....
....
added the lines:
<FilesMatch ".+\.html$">
SetHandler application/x-httpd-php
</FilesMatch>
now php parses the html files and <?php ... ?>
code works.
这篇关于阿帕奇2 Ubuntu的服务器无法解析HTML文件中的PHP code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!