0

I have this code in file called index.html in directory /var/www/html/index.html.

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

But when I try to see what it prints on the browser it doesn't show anything at all, or sometimes it downloads a file. This is what browser prints (Nothing).

If I try to look the source code and it seems like this. I'm not sure what I'm doing wrong. I searched a lot and tried a few things, but nothing really seemed to work.

I'd really appreciate if someone could list me some things to look up or where's the solution to this problem. I think it'll be very simple but I have no idea of what to do now.

edit: output of php --versionhere.

  • Don't echo it. Just call it. `echo "" > index.html` The return value, [according to the docs](http://php.net/manual/en/function.phpinfo.php), is a boolean. The call itself should print the desired info. – Matt Clark Nov 22 '17 at 23:23
  • Welp. I tried and it didn't work. The output was just `echo ""` I tried to do it on a .php file. But it keep downloading it. – Juan Cárdenas Nov 22 '17 at 23:33
  • Oops... Been a long day. Obviously it's not going to eval the php with an html extension. If you rename it to `.php` it downloads the file? Then it seems like apache is not properly configured with a PHP interpreter. – Matt Clark Nov 22 '17 at 23:35
  • Yeah! I've modified the `/etc/apache/apache2.conf' with weird lines, but it didn't work either. – Juan Cárdenas Nov 22 '17 at 23:38
  • Do you have access to the command line of this host? Can you try running `php --version` and send the output? (verify php actually is installed) – Matt Clark Nov 22 '17 at 23:41
  • I didn't figure it out how to embed an image, so edited the post. It seems to be installed. – Juan Cárdenas Nov 22 '17 at 23:46
  • Cool, so that shows you are using php7, have you enabled the Apache module? `sudo a2enmod php7.0` – Matt Clark Nov 23 '17 at 00:08
  • If it's not installed, install it, `apt-get install libapache2-mod-php` then enable it, then restart Apache. – Matt Clark Nov 23 '17 at 00:08
  • A did it both, and it output `Considering conflict php5 for php7.0: Module php7.0 already enabled`. What's next? – Juan Cárdenas Nov 23 '17 at 00:17
  • Uninstall php5 is you plan to use php7? Hmm, php7 already enabled... I am not sure.. – Matt Clark Nov 23 '17 at 00:20

0 Answers0