No mod_php? 14.04 / ondrej php5.6 + ondrej apache2

2019-07-23 22:31发布

问题:

Trying to get a 14.04 box running PHP 5.6, but having issues getting PHP enabled in apache. Specifically, it doesn't seem mod_php is being installed anymore?

apt-get update
apt-get install -y python-software-properties
add-apt-repository -y ppa:ondrej/php
add-apt-repository -y ppa:ondrej/apache2
apt-get update
apt-get upgrade -y

apt-get install -y htop apache2 php5.6 php5.6-curl php5.6-mcrypt mongodb-org curl git

a2enmod does not list php or mod_php, and locate php.ini outputs:

/etc/php/5.6/cli/php.ini
/etc/php/5.6/fpm/php.ini
/usr/lib/php/5.6/php.ini-development
/usr/lib/php/5.6/php.ini-production
/usr/lib/php/5.6/php.ini-production.cli

However including a <?php phpinfo(); in an index.php served by apache is not processed.

Help appreciated!

回答1:

TLDR

apt-get install libapache2-mod-php5.6

Long Answer

So I found the solution, which although simple, is not as intuitive as the official php packages.

After adding the apache2 and php PPA's, and installing all the packages, one needs to manually install the libapache2-mod-php5.6 package as well, which adds the php5.6 apache2 module. The confusion is that the default ubuntu php5 packages include this package as part of the install, however the ones from ondrej's PPA do not.

In case anyone wants to know or cares, I was able to solve this by searching through the closed issues on his github repo which is meant to track issues with his PPA's: Issue #266 gave me the clue.