0

Recently I a upgraded my Debian server from Jessie to Stretch (Debian 9.5). All went well except that php generated websites are not executing when requested by the web-browser. As for instances http://92.51.132.110/~mlakova/hotglue/hotglue/index.php where i get as a response the php source code and not the generated html. If I ssh onto the server and execute that same script with php index.php i get the generated html, without errors.

The php --version is PHP 7.0.30-0+deb9u1 (cli)

apache2 has module php7.0 enabled.

php5 is uninstalled and purged

The full phpinfo(); is available in http://92.51.132.110/info.php

The php error log is not showing any errors.

Anyone has leads on why this is happening and how can it be fixed? Might it have to do with the transition from mysql to mariadb?

2
  • 1
    Probably solution is shown here stackoverflow.com/questions/35928184/php-in-userdir-not-working Commented Jul 19, 2018 at 10:38
  • indeed; like stated in the answers! It was due to /etc/apache2/mods-available/php7.0.conf having "running PHP scripts in user directories is disabled by default". So commenting that directive; disabling apache module php7.0; restarting apache and enabling the module and restarted did the job! thank you! Commented Jul 19, 2018 at 11:14

2 Answers 2

4

I had this problem too. You can fix this problem with these commands. You need to install libapache2-mod and enable apache PHP mode.

Install:

sudo apt-get install apache2 php7.x libapache2-mod-php7.x 

Verify:

a2query -m php7.x

Load:

sudo a2enmod php7.x

Restart apache:

sudo service apache2 restart

And you can check.

Sign up to request clarification or add additional context in comments.

1 Comment

Great answer, thanks, solved my slightly different issue (from upgrading from buster to bullseye)
2

Solved! It was due to /etc/apache2/mods-available/php7.0.conf having the followings lines, which only required commenting.

# 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>

After it was only only a question disabling apache module php7.0; restarting apache and enabling the module and restarted did the job! thank you!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.