8

I've just upgraded to Ubuntu 18.04. Now apache serves my website's php as plaintext php. I've already tried: Why are my PHP files showing as plain text? (on Stack Overflow) and PHP 7 and apache displays plain text and cannot be restarted. The installed php packages are:

php              php7.2-cli       php7.2-fpm       php7.2-mbstring  php7.2-pgsql     php7.2-sqlite3   php7.2-zip       php-curl         php-igbinary     php-pgsql        php-xml
php7.2           php7.2-common    php7.2-gd        php7.2-mysql     php7.2-readline  php7.2-xml       php-bz2          php-fpm          php-mbstring     php-soap         php-xmlrpc
php7.2-bz2       php7.2-curl      php7.2-json      php7.2-opcache   php7.2-soap      php7.2-xmlrpc    php-common       php-gd           php-mysql        php-sqlite3      php-zip

One of the websites in question can be seen here.

The apache error.log:

[Thu Apr 26 16:02:12.740886 2018] [mpm_prefork:notice] [pid 6504] AH00169: caught SIGTERM, shutting down

[Thu Apr 26 16:02:13.001806 2018] [mpm_prefork:notice] [pid 7704] AH00163: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.0g configured -- resuming normal operations

[Thu Apr 26 16:02:13.001900 2018] [core:notice] [pid 7704] AH00094: Command line: '/usr/sbin/apache2'

And the access.log:

<MYIP> - - [26/Apr/2018:16:02:40 +0200] "-" 408 3435 "-" "-"

<MYIP> - - [26/Apr/2018:16:02:40 +0200] "-" 408 3435 "-" "-"

<MYIP> - - [26/Apr/2018:16:02:40 +0200] "-" 408 3435 "-" "-"
  • Probably you should install and enable the right Apache's php module libapache2-mod-php7.2 (and purge the old one). – pa4080 Apr 26 '18 at 14:14
  • libapache2-mod-php7.2 is already the newest version. :( – Benedikt Wutzi Apr 26 '18 at 14:15
  • Maybe you should enable it: sudo a2enmod php7.2. – pa4080 Apr 26 '18 at 14:16
  • 1
    Module php7.2 already enabled. ;) – Benedikt Wutzi Apr 26 '18 at 14:17
  • 1
    Could you write the answer as an answer then please? It would be helpful if other people stumble upon the same situation – Yann Bergonzat Apr 26 '18 at 15:05
20

This is what got my installation sorted

sudo apt install php7.2 php7.2-common php7.2-cli
sudo a2enmod php7.2
  • 2
    Thanks, to me enabling php7.2 module worked perfectly,- seems there was conflicts between multiple versions of php – Agnius Vasiliauskas Aug 28 '18 at 16:13
  • 1
    I only needed the second line a2enmod. Once that was enabled the application came up. thanks! – user1794918 Jan 20 at 3:42
4

Actually, in addition to the commands in this answer, you need

sudo apt install libapache2-mod-php

as well. Somehow it has disappeared!

0

It looks like this might be related to having 2 versions of PHP installed and enabled at the same time after the upgrade. Neither of the above worked for me, so I uninstalled Apache, PHP 7.1 and PHP 7.2, reinstalled Apache and PHP 7.2 and things are working now.

0

I ran into this while upgrading from Ubuntu 16.04.6 LTS to 18.04 LTS using the do-release-upgrade tool. In my case the following helped:

sudo apt-get install php7.2 libapache2-mod-php

This added libapache2-mod-php7.2 as well. php7.2-common and php7.2-cli were already installed, so they were ignored. sudo a2enmod php7.2 was executed automatically by apt-get.

BTW, you can diagnose this problem by creating a file /var/www/html/phpinfo.phpwith the following contents:

<?php phpinfo(); ?>

and then pointing your browser to the URL http://your.server/phpinfo.php. You should get a nice webpage with all the PHP settings. If you get the <?php phpinfo(); ?> text instead then you need to install the packages described above.

I am mentioning this because first I just ran php -v on the command line and it told me that PHP 7.2 was installed. Which is sort-of true (as the command-line stuff from the package php7.2-cli was indeed installed), but it's not the whole story. :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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