Debian 9: the php5 packages is not installed
Solution 1
The package libapache2-mod-php5.6
, php5-dev
, php5-mysql
,php5-curl
can be installed only on debian Wheezy (7) , Jessie (8) or Sid . Also the ondrej/php repository does not provide those package for debian Stretch it is only provide the php5.6
package.
The command sudo apt-get install php-dev
will install the development module for PHP7 :
dh-php libssl-dev libssl-doc php7.1-cli php7.1-common php7.1-dev php7.1-json
php7.1-opcache php7.1-readline pkg-php-tools shtool xml2
Solution 2
Open the terminal and run the following command:
apt-get install apt-transport-https lsb-release ca-certificates
Get the gpg key:
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
Add the new repository to your sources:
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
Install PHP5.6
apt-get update
apt-get install php5.6
Update
Workaround for line echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
:
Run this, and take note of the output:
lsb_release -sc
Open up /etc/apt/sources.list.d/php.list
in your editor of choice and append this to the bottom:
deb https://packages.sury.org/php/ OUTPUT_FROM_LSC_COMMAND main
Solution 3
Debian 9 does not contain PHP 5.x (see https://wiki.debian.org/PHP). To install it from the ppa, install the package php5.6
and accordingly named other packages (like libapache2-mod-php5.6
instead of libapache2-mod-php5
)
Arefe
Updated on March 23, 2020Comments
-
Arefe about 4 years
I need to install some packages to prepare the workspace for a project in the Debian 9 OS runs in a VB. I have the instruction:
---------------------------------------------------------------------- The following Debian 8 packages are required to run [X-Product]: sudo apt-get install exim4 ntp pwgen curl php5-dev php-pear pkg-config nmap libzmq3 libzmq3-dev libapache2-mod-php5 apache2 percona-server-server-5.6 php5-cli php5-mysql php5-curl php5-intl daemontools-run oracle-java8-installer ant ruby-compass libtool-bin ----------------------------------------------------------------------
When I run the command, I get the following terminal stack,
Reading package lists... Done Building dependency tree Reading state information... Done Package php5-cli is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source Package php5-mysql is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source Package php5-curl is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source Package libapache2-mod-php5 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Unable to locate package php5-dev E: Unable to locate package libzmq3 E: Package 'libapache2-mod-php5' has no installation candidate E: Package 'php5-cli' has no installation candidate E: Package 'php5-mysql' has no installation candidate E: Package 'php5-curl' has no installation candidate E: Unable to locate package php5-intl
I did some research on the internet, did the following at next,
sudo add-apt-repository ppa:ondrej/php sudo apt-get update
It doesn't help me at all. What do I need to fix this? I have very little knowledge about Debian if you ask
Note: I followed the instructions in the answer provided, the issue is still not solved like I cant see the
php version
When I run the command of
sudo apt-get install php5.6
It prints in the terminal,
Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'php5.6-json' for regex 'php5.6' Note, selecting 'php5.6-common' for regex 'php5.6' 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
To look for the
PHP
version,sudo php -v
It prints in the terminal,
sudo: php: command not found
More info like if I run it
sudo apt-get install php5-dev I get error E: Unable to locate package php5-dev
But, the command
sudo apt-get install php-dev
is successfulThe command
dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
returns value,Is that mean I hvae php7 installed and that blocks other operations?
dh-php php-cli php-common php-dev php-gd php-pear php-xml php7.0-cli php7.0-common php7.0-dev php7.0-gd php7.0-json php7.0-opcache php7.0-readline php7.0-xml pkg-php-tools
-
Arefe over 6 yearsThe
echo
command returns an error,bash: /etc/apt/sources.list.d/php.list: Permission denied
. I have tried withsudo su -c echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
after reading another post, this doesn't also help me -
Arefe over 6 yearsLastly, I have tried with the command
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/php.list
from another post and goes till to installsudo apt-get install php5.6
. This doesnt help, same erros still -
Adam Thomason over 6 yearsI've updated my answer, give the updated section a try.
-
Arefe over 6 yearsAdam, The debian name find is
stretch
and I follow all you wrote (last 2 command with sudo). Then I execute the original instruction, and still the same error. -
Nico Haase over 6 yearsWhat is the error? Which line do you finally execute to install the packages?
-
Arefe over 6 yearsI followed the other answer, also updated the question
-
Nico Haase over 6 yearsCould you try
sudo apt-get install libapache2-mod-php5.6 php5.6-cli
? -
Nico Haase over 6 yearsProbably, and this might install php7 as this is the default for Debian Stretch. Can you look in /etc/apt/sources.list.d/ to find the file containing the repository information for packages.sury.org? Or post the output of
apt-cache policy
? -
Arefe over 6 yearsThe Very helpful answer maybe the right thing to do is install Jessie (8) considering my situation.
-
Arefe almost 6 yearsAs an update, we had a complex crypto trading engine that runs only in Debian Jessie. The situation might be different for the other people.
-
Tiziano Mischi over 5 yearsThis solution is good for me with debian 9 but the php5.6 version there's on the sury distribution is not complete. It misses something essential like pdo or xmlreader. At least they've not been installed for me. Where can i find those packages? thanks
-
Adam Thomason over 5 years@TizianoMischi I think this might be a good start: stackoverflow.com/questions/8464784/…
-
user1278519 over 4 yearsthat installed php7, op asked about php5
-
ryancdotnet over 4 yearsIIRC, I was pointing out that PHP's documentation on installation does not account for special considerations around specific distros. If one is trying to get PHP installed on a newer distro, and just following the instructions on PHP's site, this information may be useful. I'm not even sure OP requires version 5.6 actually. But I hope this may help some poor soul in the future (Unless they have updated their docs by now...??)