Apache 显示 PHP 的空白页面

Apache 显示 PHP 的空白页面

我安装了新版本Centos 7,我是 Linux 新手。

我使用安装了 Apache yum -y install httpd,可以打开测试页面,一切正常。

之后我使用安装了PHP(5.4.16)yum -y install php并成功安装。

之后我使用 重新启动了 Apache sudo systemctl restart httpd。现在我info.php用以下代码创建了一个文件:

<php
phpinfo();
?>

当我打开时,http://localhost/info.php我看到一个空白屏幕,里面什么也没有。

我已经阅读了很多与此相关的主题和问题,我做了一切,但没有任何帮助。
以下是可能对您有帮助的事情。

错误日志:

[Sat Mar 12 12:56:33.235215 2016] [core:notice] [pid 12938] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sat Mar 12 12:56:33.236027 2016] [suexec:notice] [pid 12938] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Mar 12 12:56:33.251732 2016] [so:warn] [pid 12938] AH01574: module php5_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Sat Mar 12 12:56:33.253398 2016] [auth_digest:notice] [pid 12938] AH01757: generating secret for digest authentication ...
[Sat Mar 12 12:56:33.266274 2016] [lbmethod_heartbeat:notice] [pid 12938] AH02282: No slotmem from mod_heartmonitor
[Sat Mar 12 12:56:33.271424 2016] [mpm_prefork:notice] [pid 12938] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Sat Mar 12 12:56:33.271462 2016] [core:notice] [pid 12938] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Mar 12 12:58:08.594101 2016] [:error] [pid 12940] [client ::1:44873] script '/var/www/html/info.php' not found or unable to stat
[Sat Mar 12 13:01:56.086456 2016] [mpm_prefork:notice] [pid 12938] AH00170: caught SIGWINCH, shutting down gracefully
[Sat Mar 12 13:02:55.938198 2016] [core:notice] [pid 1400] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
[Sat Mar 12 13:02:56.048201 2016] [suexec:notice] [pid 1400] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Mar 12 13:02:56.077712 2016] [so:warn] [pid 1400] AH01574: module php5_module is already loaded, skipping
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Sat Mar 12 13:02:56.079255 2016] [auth_digest:notice] [pid 1400] AH01757: generating secret for digest authentication ...
[Sat Mar 12 13:02:57.017924 2016] [lbmethod_heartbeat:notice] [pid 1400] AH02282: No slotmem from mod_heartmonitor
[Sat Mar 12 13:02:57.038794 2016] [mpm_prefork:notice] [pid 1400] AH00163: Apache/2.4.6 (CentOS) PHP/5.4.16 configured -- resuming normal operations
[Sat Mar 12 13:02:57.038866 2016] [core:notice] [pid 1400] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

Apache 配置文件:库存文件

php.ini :库存文件

.htaccess:没有文件

答案1

您缺少?开始标签中的 。它应该是:

<?php
phpinfo();
?>

答案2

尝试启用错误报告:

<?php

error_reporting(E_ALL);
phpinfo();

?> 

答案3

我也遇到过这个错误,我所做的是添加php.conf/etc/httpd/conf.d.

相关内容