13

After I upgraded to Ubuntu 17.10, PHP totally stopped working. Everything works fine in Ubuntu 17.04. The code for info.php as follows does not work:

<?php 
phpinfo();
?>

It is not showing PHP information, it only shows the source code like above.

pomsky
  • 68,507

4 Answers4

33

Open terminal with ALT + CTRL + T and type in these commands:

sudo a2enmod php7.1
sudo systemctl restart apache2
TheOdd
  • 3,012
5

libapache2-mod has been upgraded from libapache2-mod-php7.0 in Ubuntu 17.04 to libapache2-mod-php7.1 in Ubuntu 17.10 and Ubuntu 18.04. Open the terminal and type:

sudo apt install libapache2-mod-php7.1 # install PHP7 module for Apache2 webserver
sudo a2enmod php7.1 # enable the PHP7 module
sudo systemctl restart apache2.service # restart apache
karel
  • 114,770
  • Better: install the libapache2-mod-php metapackage so you have nothing more to do when 7.2 comes around. ;) – fkraiem Nov 24 '17 at 10:46
0

Try the following:

  1. sudo apt-get install libapache2-mod-php
  2. Place code to the /var/www/html/phpinfo.php:
<?php
  phpinfo();
?>
  1. Navigate web-browser to http://localhost/phpinfo.php.

Note: method is applicable to Ubuntu 18.04 LTS too.

N0rbert
  • 99,918
-2

I also had that problem on Ubuntu 17.10, but only my Firefox 57.0.1 (64bit) couldn't open the phpinfo and the phpmyadmin (and wordpress) files.

The tips in the other answers didn't help me. I reinstalled LAMP-Server and Firefox. Still the same. Finally I installed Chromium and there phpinfo and phpmyadmin work.

Also, Firefox 57 from another fresh installed Ubuntu 17.10 can open phpinfo and phpmyadmin. It looks like something went wrong during do-release-upgrade.

Zanna
  • 70,465