I'm running Ubuntu 14.04 with Apache2 and PHP7.

For some reason,probably after I updated the PHP version,it is no longer executing. This is the output of

php -v:

PHP 7.0.8-3+deb.sury.org~trusty+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.8-3+deb.sury.org~trusty+1,
Copyright (c) 1999-2016, by Zend Technologies

The root folder is /var/www/html

The PHP.conf is configured correctly,I believe.

When I add

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 

And try to load a PHP script then it gets downloaded and not loaded in the browser.

Any ideas?

I appreciate it!


1 Answer 1


You should be able to fix your problem by running the following commands

sudo apt-get install libapache2-mod-php7.0
sudo a2dismod php*
sudo a2enmod php7.0
sudo apache2ctl restart

After adding Ondrej's repository, installing PHP 7 may not be enough as you will also need to install and enable Apache's PHP module for the version of PHP you need.

This may be reason why PHP works in CLI mode, but not with Apache.

Note: I haven't tested sudo a2dismod php* on Ubuntu 14.04, but in case it doesn't work, just type sudo a2dismod php and tap the tab button so php auto-completes to whichever PHP version is enabled.

  • When I execute the second command,it says I should restart apache. I do,and I get apache2: Could not reliably determine the server's fully qualified domain name, using Set the 'ServerName' directive globally to suppress this message
    – wadie
    Jul 5, 2016 at 17:21
  • When I tap the tab button it auto completes to sudo a2dismod php5.conf~
    – wadie
    Jul 5, 2016 at 17:23
  • @wadie that is not an error, it's more of a notice, you can fix it by following this answer askubuntu.com/a/396048/8698. As for your second comment, is PHP 7 still not working with Apache? Are there any errors you're still having? (sorry I'm currently on my phone, but I'll help as much as I can)
    – Dan
    Jul 5, 2016 at 17:40

You must log in to answer this question.

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