phpinfo() 在我的 CentOS 服务器上不起作用 [英] phpinfo() is not working on my CentOS server

查看:14
本文介绍了phpinfo() 在我的 CentOS 服务器上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 CentOS 服务器上安装了 PHP.但是,当在我的脚本中运行 phpinfo() 来测试它时,我收到的是 HTML,而不是解释的信息.

I have PHP installed on my CentOS server. However, when running a phpinfo() inside my script to test it, I receive the HTML, not the interpreted information.

我可以看到 PHP 的文件夹.我什至可以在 etc 文件夹中看到 php.ini.但是 PHP 本身似乎不起作用.

I can see the folders for PHP. I can even see the php.ini in the etc folder. But PHP itself does not seem to be working.

我的意思是我的 test.php 文件看起来像这样:

I mean my test.php file looks like this:

<?php
    phpinfo();
?>

响应如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
...

等等.

问题似乎是什么,我该如何解决?

What seems to be the problem and how do I solve it?

如果我复制返回的 HTML,将其粘贴到 HTML 文件中,然后从那里运行它,我可以看到格式化的结果,但不能通过运行 test.php.我假设 PHP 没有以某种方式加载......即使在解释的 HTML 中我可以看到:

If I copy the HTML returned, paste it into an HTML file, and run it from there, I can see the formatted result, but not by running the test.php. I assume PHP is not loaded somehow... even if in the interpreted HTML I can see the:

**Server API    Apache 2.0 Handler
Virtual Directory Support    disabled
Configuration File (php.ini) Path    /etc/php.ini
Scan this dir for additional .ini files    /etc/php.d
additional .ini files parsed    /etc/php.d/dbase.ini, /etc/php.d/json.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini
PHP API    20041225
PHP Extension    20050922
Zend Extension    220051025
Debug Build    no
Thread Safety    disabled
Zend Memory Manager    enabled
IPv6 Support    enabled
Registered PHP Streams    php, file, http, ftp, compress.bzip2, compress.zlib, https, ftps**

等等……

在这个系统上,托管了三个网站.和这个问题有关系吗?

On this system, there are three websites hosted. Does that have anything to do with this problem?

推荐答案

这也发生在我身上.修复将其包装在 HTML 标记中.然后我将文件保存为 /var/www/html/info.php 并运行 http://localhost/info.php 在浏览器中.就是这样.

This happened to me as well. The fix was wrapping it in HTML tags. Then I saved the file as /var/www/html/info.php and ran http://localhost/info.php in the browser. That's it.

<html>
    <body>
        <?php
            phpinfo();
        ?>
    </body>
</html>

这篇关于phpinfo() 在我的 CentOS 服务器上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆