阿帕奇:内联PHP不工作在Linux上[解决] [英] Apache: Inline PHP not working on Linux [SOLVED]
问题描述
我有麻烦我的PHP为我的Apache服务器的工作。我运行Oracle Linux和使用 yum的安装PHP
+ 百胜安装的httpd
来得到我的PHP和Apache。我已经走遍了互联网,并做了几件事情:
I am having trouble getting my PHP to work for my Apache server. I am running Oracle Linux, and used yum install php
+ yum install httpd
to get my PHP and Apache. I have scoured the internet and done a couple of things:
首先,我已经进入我的httpd.conf文件,并添加的LoadModule php5_module模块/ libphp5.so
。我选择使用一个在我php.conf文件,该文件是完全相同的。此外,我已经做了将AddType应用程序/ x-HTTP-PHP的.php
,所以现在我的PHP文件加载罚款。
Firstly, I have gone into my httpd.conf file and added LoadModule php5_module modules/libphp5.so
. I have chosen to use the one in my php.conf file, which is the exact same one. Furthermore, I have done AddType application/x-http-php .php
, so now my .php files are loading fine.
其次,我试图运行我的Apache服务器,并能正常工作。它显示我的index.html文件,这是我设定的DirectoryIndex。然而,当我试图把PHP code,不过它得到了自动注释掉了,我以为是因为我还没有将其设置为在服务器端正确执行。
Secondly, I have tried to run my Apache server, and it works fine. It displays my index.html file, which I set with DirectoryIndex. However, when I tried to put php code into it, it got automatically commented out, which I assume is because I haven't set it to properly execute on the server side.
现在,与所有的说,我不知道我可能会丢失什么。我有两个调校的一间是我有一个PHP文件,一个地方PHP是内嵌在HTML
Now, with all that said, I am wondering what else I may be missing. I have two set-ups, one where I have a .php file, and one where the php is inline with the html.
的index.html
<!DOCTYPE html>
<body>
<?php echo "Hello everybody."; ?>
</body>
</html>
的index.php
<?php phpinfo(); ?>
index.php文件加载罚款,但index.html的不运行PHP的code。我如何让PHP的版本内联工作的?
The index.php file loads fine, but the index.html doesn't run the php code. How do I get the inlined version of php to work?
任何帮助将是AP preciated。谢谢!
Any help would be appreciated. Thank you!
注意:我建立我的Mac OS做工精细用.php文件,但它也有一个HTML文件中嵌入PHP的麻烦。我缺少什么?
Note: I have set-up my Mac OS to work fine with .php files, but it is also having trouble with inline php within an Html file. What am I missing?
解决方案: HTML文件本身不能包括PHP。相反,文件必须是PHP扩展和PHP文件中,可以有文本,HTML和JavaScript。
SOLUTION: Html files themselves cannot include php. Instead, the file must be a .php extension, and within a .php file, you can have text, html, and JavaScript.
推荐答案
我不认为.html文件通过PHP在所有这样的&lt;?运行...&GT?;被视为普通标签,它是不可见的。
I do not think .html files are run through php at all so the <? ... ?> is treated as a normal tag which is invisible.
将扩展名改为.PHP。
Change the extension to .php.
PHP可以包含HTML。
Php can contain html.
这篇关于阿帕奇:内联PHP不工作在Linux上[解决]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!