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.

  • 1
    your code is wrong <?php phpinfo(); ?> – Lynob Oct 22 '17 at 17:29
  • 2
    please read the formatting guide and format your code as code. I cannot tell whether the backslashes are in your code or just your attempt to format the post – Zanna Oct 22 '17 at 17:57
  • 2
    This section of the markdown help shows how to include readable blocks of code in a post. – Eliah Kagan Oct 22 '17 at 18:09

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

sudo a2enmod php7.1
sudo systemctl restart apache2
  • 1
    @ShenHongliang If you find this answer useful you may "accept" it by clicking on the tick mark (✓) next to it. – pomsky Oct 23 '17 at 12:31

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
  • 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

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.

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.