search

Home  >  Q&A  >  body text

php7 - Under ubuntu16, Apache2 parses php and displays source code

On ubuntu, apache can only display the source code when parsing php
When accessing http://localhost/, it shows that it works!

Then I wrote a phpinfo.php and placed it in /var/www/html. The code is:

<?php
        echo phpinfo();
?>

Then I tried to access it

Then I tried to modify the php configuration file, but I couldn't find this file. There was only one conf.d file under /etc/php/7.0/apache2/, and there was no php.ini file in it, so I just Even more puzzled.
Finally I changed the code of phpinfo.php:

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<?php
        echo phpinfo();
?>

</body>
</html>

At this time, what is parsed is a blank page

So, how can we solve the problem of parsing php like this and only displaying the source code?

为情所困为情所困2747 days ago965

reply all(1)I'll reply

  • 滿天的星座

    滿天的星座2017-05-16 17:00:55

    $$ a2dismod mpm_event && a2enmod mpm_prefork && a2enmod php7.0

    reply
    0
  • Cancelreply