1

I can't run PHP scripts on my localhost, the browser renders a white screen. If I view the source of the page I can see the contents of the PHP file visibly.

Using:

$ sudo apt-get install libapache2-mod-php7.0 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libapache2-mod-php7.0 is already the newest version (7.0.6-6+donate.sury.org~xenial+1).
The following packages were automatically installed and are no longer required:
libgsoap8 libvncserver1
Use 'sudo apt autoremove' to remove them.
0 to upgrade, 0 to newly install, 0 to remove and 15 not to upgrade.

Suggests the module is installed. Upon trying to enable it:

$ sudo a2enmod php7.0
ERROR: Module php7.0 does not exist!

PHP is installed:

$ php -v
PHP 7.0.6-6+donate.sury.org~xenial+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

I tried this tutorial https://ivan.reallusiondesign.com/install-php-7-on-ubuntu/

only when i reach

$ sudo a2enmod php7.0
ERROR: Module php7.0 does not exist!

I'm running out of ideas. If you could help me get PHP7 to run on Apache/2.4.18 (Ubuntu) that would be good thanks.

cookie
  • 65
  • 4
  • 11
  • The official Ubuntu 16.04 package is [`libapache2-mod-php7.0 (7.0.4-7ubuntu2) `](http://packages.ubuntu.com/xenial/libapache2-mod-php7.0), which makes me wonder if you have somehow got your hands on something outside of the Ubuntu Main repository. The little bit in the middle (i.e., "donate.sury.org") makes me wonder even more! – Colt May 11 '16 at 17:22

3 Answers3

2

The official Ubuntu 16.04 package is libapache2-mod-php7.0 (7.0.4-7ubuntu2), but it looks like you have gone outside of the supported software (i.e., the Ubuntu Main repository) following instructions sudo add-apt-repository ppa:ondrej/php in your link. Get rid of this, get rid of the ppa, and use the officially supported php 7.0 from the Ubuntu Main respository.

That said, it also looks like you may have installed libapache2-mod-php without also installing php. Using the "official" (supported) repository, the Ubuntu 16.04 Server Guide's Web Server section for PHP would suggest that the correct install command is:

sudo apt install php libapache2-mod-php

Finally, it looks like the ppa you are using was prepared for Ubuntu 14.04, as opposed to Ubuntu 16.04. There are significant differences between these versions, not the least being use of systemd as the init system. It is very conceivable that the "version" you obtained may have substantial issues on Ubuntu 16.04.

Colt
  • 1,939
  • 6
  • 20
  • 25
  • Removing all traces of LAMP and the PPAs and using Synaptic to re-install it finally worked for me. – cookie May 12 '16 at 12:29
2

That "guide" was written by me, and it was targeting 14.04, when php 7 was still not officially released. Currently it might not even work on 14.04 as the package maintainer might have changed the package names.

Sorry for the inconvenience.

pennywise
  • 31
  • 3
1
  1. sudo apt purge libapache2-mod-php7.2 libapache2-mod-php7.2

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

  3. sudo a2enmod php7.2

  4. systemctl restart apache2

This works in the 7.2 version, just add at the end of php -> 7.2

Stuggi
  • 3,366
  • 4
  • 17
  • 34