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.

3
  • 1
    your code is wrong <?php phpinfo(); ?>
    – Lynob
    Oct 22, 2017 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, 2017 at 17:57
  • 2
    This section of the markdown help shows how to include readable blocks of code in a post. Oct 22, 2017 at 18:09

4 Answers 4

33

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

sudo a2enmod php7.1
sudo systemctl restart apache2
3
  • 1
    @ShenHongliang If you find this answer useful you may "accept" it by clicking on the tick mark (✓) next to it.
    – pomsky
    Oct 23, 2017 at 12:31
  • THIS ANSWER SAVED MY WHOLE LIFE AND CAREER! THANKS!! Mar 1, 2020 at 17:16
  • Thanks a lot, this really helped me. Sep 22, 2022 at 11:56
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
1
  • Better: install the libapache2-mod-php metapackage so you have nothing more to do when 7.2 comes around. ;)
    – fkraiem
    Nov 24, 2017 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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .