1

I know this is probably most discussed topic online, I did search here and stackexchange and tried various answers but none of them seems to be working for me, hence why I am posting this.

I have a Debian with LAMP stack and recently had to upgrade php from 5.4 to 5.6 (latest).

I began by removing the old version like this:

a2dismod php5

sudo apt-get --remove --purge libapache2-mod-php5filter libapache2-mod-php5 libphp5-embed php-pear php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-mcrypt php5-mysql

Added the following to my /etc/apt/sources.list file:

deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all
deb http://packages.dotdeb.org wheezy-php56-zts all
deb-src http://packages.dotdeb.org wheezy-php56-zts all

And ran the following commands:

wget https://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libapache2-mod-php5 php-pear php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-mcrypt php5-mysql php5-mysqlnd

Then I enabled php5 with this command a2enmod php5 and restarted apache2 with this command service apache2 restart

When I go to one of the PHP scripts on the site, I am seeing the source, the script is not getting executed.

On the server, I can see that PHP5.6 is correctly installed:

root@server:~# php -v
PHP 5.6.18-1~dotdeb+zts+7.1 (cli) (built: Feb  6 2016 23:39:42) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

And I can see that PHP5 module is enabled in apache2:

enter image description here

Here are the contents of these files:

I even tried restarting the whole server, it does not help. I've checked /var/log/apache2/error.log and I do not see any errors. All I see is:

[Tue Feb 09 12:52:09 2016] [notice] Digest: generating secret for digest authentication ...
[Tue Feb 09 12:52:09 2016] [notice] Digest: done
[Tue Feb 09 12:52:09 2016] [notice] Apache/2.2.22 (Debian) mod_ssl/2.2.22 OpenSSL/1.0.1e configured -- resuming normal operations

I use VirtualHost in apache2 to serve the site. This is is my entry:

<VirtualHost *:80>

    ServerAdmin [email protected]
    ServerName www.mydomain.com
    DocumentRoot /home/setup/public_html

    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    <Directory /home/setup/public_html/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

</VirtualHost>

Any idea why the PHP script is not getting executed? What I have missed? Any help would be greatly appreciated.

2
  • Check to see if engine is set to on in the php.ini file and use apache2ctl -M to check if php5_module is loaded
    – Spokey
    Feb 9, 2016 at 13:39
  • I have checked apache2/php.ini, apache2filter/php.ini & cli/php.ini from /etc/php5 dir and yes engine = On. And here's the output for apache2ctl -M (I can see php5_module (shared)) - pastebin.com/AxkJmp4p
    – Latheesan
    Feb 9, 2016 at 13:46

1 Answer 1

0

Okay, I have fixed it.

I have removed the following:

# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

From /etc/apache2/mods-enabled/php5.conf and restarted apache and PHP now works.

You must log in to answer this question.

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