[英]Loading a PHP file in Chrome displays PHP codes
The Problem: 问题:
Exactly as it says. 正如它所说的那样。 My phpinfo.php file contains the following:
我的phpinfo.php文件包含以下内容:
<?php phpinfo(); ?>
The file itself is located in /var/www/html/info.php
. 该文件本身位于
/var/www/html/info.php
。
What I did (prior to the problem): 我做了什么(在问题出现之前):
I erased all installations of PHP, oci8, and what not. 我删除了PHP,oci8的所有安装,什么不是。 I'm not sure if I did a good job - basically, I typed in
yum history
and then undid every install relating to PHP. 我不确定我是否做得很好 - 基本上,我输入了
yum history
然后解除了与PHP相关的每个安装。
This was so I could have a clean system (supposedly), before trying all the PHP stuff again, without resorting to a reformat - I had Oracle 11g and apache already setup there. 这样我就可以有一个干净的系统(据说),再次尝试所有PHP的东西,而不需要重新格式化 - 我已经安装了Oracle 11g和apache。
Take note, before this complete wipeout, said file up there was working fine. 请注意,在此完全消除之前,说文件在那里工作正常。
To install PHP with oci8, I followed a guide here , with some differences, but I'll list it down, just the same. 要使用oci8安装PHP,我在这里遵循了一个指南,但有一些不同之处,但我会将其列出来,同样如此。
Afterwards, I added the following at the very end of /etc/php.ini
file: 之后,我在
/etc/php.ini
文件的最后添加了以下内容:
[OCI8] [OCI8]
extension=oci8.so 延长= oci8.so
Then, I restarted apache via service httpd restart
. 然后,我通过
service httpd restart
启动了apache。
And then, I encountered the problem. 然后,我遇到了问题。
The System: 系统:
What I tried: 我尝试了什么:
I thought at first it was Konqueror's problem. 我一开始以为这是Konqueror的问题。 Fiddling with the View settings sometimes fixed it - most of the time, it did nothing.
摆弄视图设置有时会修复它 - 大多数时候,它什么也没做。
So I installed Google Chrome, which displayed the same thing. 所以我安装了Google Chrome,它显示了同样的东西。
At this point I went, what the heck, I just installed php via yum install php
. 此时我去了,我刚刚通过
yum install php
。 Maybe php-pear
or php-devel
on its own is not enough to run a php file. 也许
php-pear
或php-devel
本身不足以运行php文件。
No dice. 没有骰子。 All I wanted was to start over and install PHP with oci8 from scratch.
我想要的只是重新开始并从头开始用oci8安装PHP。
It appears PHP itself has a problem, and I'm stuck. 看起来PHP本身有问题,而且我被卡住了。 A bit of research online says something about the tags, that php can't run
<?.... ?>
, as opposed to <?php ..... ?>
, but as you can see with my phpinfo example, it didn't help much. 网上的一些研究说明了标签,php不能运行
<?.... ?>
,而不是<?php ..... ?>
,但正如你可以看到我的phpinfo示例,它没有多大帮助。
Other Information: 其他信息:
I get this from PHP's error log. 我从PHP的错误日志中得到了这个。 I'm not sure if it means anything, as I recall seeing something like this back before I nuked my system, but perhaps they can be of some use.
我不确定它是否意味着什么,因为我记得在我修改系统之前看到过这样的东西,但也许它们可能有用。
AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.php) found, and server-generated directory index forbidden by Options directive
AH01276:无法提供目录/ var / www / html /:找不到匹配的DirectoryIndex(index.html,index.php),以及Options指令禁止的服务器生成的目录索引
AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
AH00094:命令行:'/ usr / sbin / httpd -D FOREGROUND'
They don't seem to appear in the error log at any predictable frequency - loading up any PHP file or restarting apache are the only two things I've done. 它们似乎没有以任何可预测的频率出现在错误日志中 - 加载任何PHP文件或重新启动apache是我做过的唯一两件事。
It's not the browser. 这不是浏览器。 Probably, you don't have php module activated in your Apache.
可能你没有在Apache中激活php模块。 Look at your httpd.conf, and put the following lines there:
查看你的httpd.conf,并在其中添加以下行:
# Load the PHP module:
LoadModule php5_module lib/httpd/modules/libphp5.so
# Tell Apache to feed all *.php files through PHP. If you'd like to
# parse PHP embedded in files with different extensions, comment out
# these lines and see the example below.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.