PHP shows up as plain text after upgrade to 18.04

11,271

Solution 1

This is what got my installation sorted

sudo apt install php7.2 php7.2-common php7.2-cli
sudo a2enmod php7.2

Solution 2

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

sudo apt install libapache2-mod-php

as well. Somehow it has disappeared!

Share:
11,271

Related videos on Youtube

Benedikt Bergenthal
Author by

Benedikt Bergenthal

Updated on September 18, 2022

Comments

  • Benedikt Bergenthal
    Benedikt Bergenthal over 1 year

    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 "-" "-"
    
    • pa4080
      pa4080 about 6 years
      Probably you should install and enable the right Apache's php module libapache2-mod-php7.2 (and purge the old one).
    • Benedikt Bergenthal
      Benedikt Bergenthal about 6 years
      libapache2-mod-php7.2 is already the newest version. :(
    • pa4080
      pa4080 about 6 years
      Maybe you should enable it: sudo a2enmod php7.2.
    • Benedikt Bergenthal
      Benedikt Bergenthal about 6 years
      Module php7.2 already enabled. ;)
    • pa4080
      pa4080 about 6 years
      Try to flush your browsers cache. This is the last idea that I have :)
    • Benedikt Bergenthal
      Benedikt Bergenthal about 6 years
      well that simple solution did the trick. Thanks a lot for the new perspective :)
    • pa4080
      pa4080 about 6 years
      I'm glad to help!
    • Lily Bergonzat
      Lily Bergonzat about 6 years
      Could you write the answer as an answer then please? It would be helpful if other people stumble upon the same situation
  • Agnius Vasiliauskas
    Agnius Vasiliauskas over 5 years
    Thanks, to me enabling php7.2 module worked perfectly,- seems there was conflicts between multiple versions of php
  • user1794918
    user1794918 over 5 years
    I only needed the second line a2enmod. Once that was enabled the application came up. thanks!