I am using following instruction to install latest php on unbutu instance:
Add to /etc/apt/source.list
deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
Update apt-key
sudo wget -q http://www.dotdeb.org/dotdeb.gpg
sudo apt-key add dotdeb.gpg
sudo apt-get update
install apache2 + php
`sudo apt-get install -y apache2 php5 libapache2-mod-php5`
Output:
The following packages have unmet dependencies:
libapache2-mod-php5 : Depends: libxml2 (>= 2.8.0) but 2.7.8.dfsg-5.1ubuntu4 is to be installed
Recommends: php5-cli but it is not going to be installed
I need a stable way to install latest php. Previously I was using ppa and decided to not use it bcz of security
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5-oldstable
I wonder if there is a better way to setup latest php+apache2+mysql , I have to script the process to automate the installation and invoke it through build script
Side note/problem background:
I am using Phing ssh task to invoke the script to setup php+apache2+mysql, which break with add-apt-repository command for weird reason
Reference:
<ssh host="${deploy.host}"
username="${deploy.user}"
privkeyfile="${deploy.pem}"
pubkeyfile="${deploy.pub}"
command="${ssh_command}"
display="false"
property="ssh.output"
failonerror="true"
/>
ssh_command where I invoke the script
Further tests:
sudo apt-get install -y apache2 php5 php5-cli libapache2-mod-php5 php5-mysql php5-gd php5-memcache php5-mcrypt php5-xsl
Output:
The following packages have unmet dependencies:
libapache2-mod-php5 : Depends: libxml2 (>= 2.8.0) but 2.7.8.dfsg-5.1ubuntu4 is to be installed
php5-cli : Depends: libxml2 (>= 2.8.0) but 2.7.8.dfsg-5.1ubuntu4 is to be installed
Depends: libedit2 (>= 2.11-20080614-4) but 2.11-20080614-3ubuntu2 is to be installed
E: Unable to correct problems, you have held broken packages.
I had a similar situation.
The place where I was working was using an old version on PHP (5.3.8).
I installed the latest version of Ubuntu in my desktop and then I realised that downgrading from 5.5 to 5.3 was almost impossible, too many dependencies to handle, the best solution I could find was to use an "all-in-one" package like XAMPP.
Even though I hate those solutions I changed my mind after a couple of hours, it did exactly what it was supposed to do, I didn't have to do any sorcery in the package manager or alter any configuration files.
Here is the XAMPP version I would use in your case (1.8.2-3 version - PHP 5.4 based)
It contains
PHP 5.4.22
MySQL 5.5.34
Apache 2.4.7
phpMyAdmin 4.0.9
More info: here and here
Related
My worpdress website site health page dispalyas apossible improvement - php module intl missing.
My server has multiple versions of php (8.1 &8.2) active.
I use the following ssh command to install the missing intl module-
apt-get install -y php-intl
But get tis error message.
The following packages have unmet dependencies:
php8.1-intl : Depends: php8.1-common (= 8.1.2-1ubuntu2.10) but 8.1.14-1+ubuntu18.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.
the php modules which are active om my server , like imagick, are installed for php8.1. but my active php version is 8.2.
The problem is with the dependencies of the "php8.1-intl" package. Specifically, it requires version 8.1.2-1ubuntu2.10 of the "php8.1-common" package, but the version that is currently available is 8.1.14-1+ubuntu18.04.1+deb.sury.org+1, which is causing a conflict.
try:
sudo apt update
sudo apt-get check
sudo apt-get install -f
sudo dpkg --configure -a
5.sudo apt-get install php8.1-common=8.1.2-1ubuntu2.10
6.sudo apt-get install php8.1-intl
You may need to remove the conflicting package(s) and installing the required packages again. But be careful when removing packages as it may cause other dependencies to break.
I am trying to install PHP mbstring module in my Ubuntu 14.04 machine. I've used "sudo apt-get -f install php7.0-mbstring" to install the module. I've added necessary source list in "/etc/apt/sources.list".
When I run the above mbstring installation command I get the following error.
The following packages have unmet dependencies:
php7.0-mbstring : Depends: php7.0-common (= 7.0.33-0ubuntu0.16.04.6) but 7.0.21-1~ubuntu14.04.1+deb.sury.org+1 is to be installed
Conflicts: php7.0-mbstring:i386 but 7.0.33-0ubuntu0.16.04.6 is to be installed
php7.0-mbstring:i386 : Depends: php-common:i386 (>= 1:33) but it is not installable
Depends: php7.0-common:i386 (= 7.0.33-0ubuntu0.16.04.6) but it is not going to be installed
Depends: libc6:i386 (>= 2.4) but it is not going to be installed
Conflicts: php7.0-mbstring but 7.0.33-0ubuntu0.16.04.6 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
What is the recommended solution here? Do I need to uninstall PHP 7.0 and reinstall or is there any other low risk solution?
Edit: I've tried to install with sudo apt-get -f install as well. I get the same following error,
php7.0-mbstring:i386 : Depends: php-common:i386 (>= 1:33) but it is not installable
Depends: php7.0-common:i386 (= 7.0.33-0ubuntu0.16.04.6) but it is not installed
Depends: libc6:i386 (>= 2.4) but it is not installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies
First be sure that your package list is up to date, try:
sudo apt-get update
After it try install packeage again
sudo apt-get install php7.0-mbstring
If it doesn't help try to add php repository to source list, for example you can use this PPA
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0-mbstring
I tried installing php in ubuntu 16.04 using following command:
sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7
but it says
Unable to locate package libapache2-mod-php7
Should I skip this or install by an alternative way?
The name of the package is libapache2-mod-php7.0
Try again by having that .0 at the end and it should work.
On Ubuntu 18.04, I had to add the repository below first. Once the repo was added I was able to install the php7.x items.
sudo add-apt-repository ppa:ondrej/php
Source: https://websiteforstudents.com/apache2-with-php-7-1-support-on-ubuntu-18-04-lts-beta-server/
If you are using Ubuntu 17.04/17.10 or above use php7.1 instead of 7.0 since it is no longer available.
sudo apt-get install php7.1
At the time of the post Ubuntu 16.04 was one of the newer versions and as such the packages changed to php7.0 but as time goes on it will be 7.1 to 7.2 etc... and I don't have the time to figure out what was the latest package and I'm not dependent on a specific version.
So if you want the latest version of packages to install without having to know the correct version number just drop the version number and the latest applicable to the distribution you are using will be installed.
In my case I was using Ubuntu 17.10 and the php version is different so I used the following command line to get the latest.
sudo apt-get install apache2 php-mysql libapache2-mod-php mysql-server
It installed php 7.1 and all of the correct dependencies.
So if you don't require a specific version but just want the latest that works with the distribution drop the version number and use the command line above.
It is likely the case that your local package index is not updated; try
sudo apt-get update
and then run the previous command again.
As an aside, there is now a program apt that is supposedly more user-friendly than apt-get, apt-cache etc. (see this question on Ask Ubuntu). So your commands could have been replaced by
sudo apt update
sudo apt install <the packages>
to get a slightly nicer user interface.
Probably this question would have been better suited to the Ask Ubuntu community.
Apache server can't start because libapache2-mod-php7.0 is not installed:
by default aptitude or apt install php7.0-common version 7.8.13 which is not adaptable and libapache2-mod-php need 7.0.8
remove php-common
download http://packages.ubuntu.com/xenial/php7.0-common deb package and install it if it compains about php7.0-json, readline,cli,opache
then seatch in upper textbox about those library and install them in this manner
json
opach
cli
readline
install libapache2-mod-php7.0
RESTART APACHE 2
service apache2 restart
it must working probably
Good Luck!
Try for Ubuntu 16.04:
sudo apt-get update;
sudo apt-get install php7.0-fpm php7.0-mysql <other packages>;
for Ubuntu 14.04:
sudo apt-get update;
sudo apt-get install php5-mysql php5-mysql <other packages>;
It should be:
sudo apt-get install libapache2-mod-php7.0
sudo apt-get install libapache2-mod-php7.1
worked for me (16.04Ubuntu).
If you getting error like php7.2 php7.2-curl libapache2-mod-php doesn't have installable candidate or not locate any package or dependencies is php7.2-common Or libcurl3 Do this . Remeber Change your package name as per your requirements
You have to tackle in mature way. Install aptitude these ubuntu package manager will finds all dependencies, and will install one by one.
apt-get install aptitude
Now you have to check if aptitude can download it or not if download it follow instructions
sudo aptitude install php7.2-curl
If you have gotten any error like this
E: Unable to locate package php7.2-curl
E: Couldn't find any package by glob 'php7.2-curl'
Any type on error i'm not talking about proper these errors
Try to add php package again
sudo apt-add-repository ppa:ondrej/php
sudo apt-get update
Now try this command
sudo aptitude install php7.2-curl
Aptitude will ask you you want to keep current version of all dependencies
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) php7.2-curl [Not Installed]
Accept this solution? [Y/n/q/?]
Type n then Enter
Aptitude will find all dependencies and ask you to install all package type
y
Again
y
Then
systemctl restart apache2
For centos of rhel
systemctl restart httpd
It will Not enabling PHP 7.2 FPM by default.
NOTICE: To enable PHP 7.2 FPM in Apache2 do
a2enmod proxy_fcgi setenvif
a2enconf php7.2-fpm
This method is not only for this error you can find any of php apache2 or ubuntu system package solution using aptitude.
Upvote if you find your solution
Looks like we need to install the same version of libapache2-mod-php as the version of php present .I had php 7.4 installing libapache2-mod-php7.4 solved the problem.Thanks
just test upper versions of php
for example run:
sudo apt-get install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.0 libapache2-mod-php7.4
I have been installing php7.0-fpm via ppa:ondrej/php on Ubuntu using the following commands without issue over the last few months whilst preparing my new server;
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php7.0-fpm
Today, I tried to install again using the same commands as above, and now I get a failure with the final command as follows;
root#10:/etc/apt/sources.list.d# apt-get install php7.0-fpm
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php7.0-fpm
E: Couldn't find any package by regex 'php7.0-fpm'
Any clues as to why this install command set has suddenly stopped working?!
The same error is recorded when trying to install php7.0-mysql, which again was working fine until recently.
Many thanks in advance,
Dave
I have found a resolution for this as shown below.
The Ubuntu version I was using was 15.04, which is now out of support.
After upgrading my install to Ubuntu 15.10 the installation of php7.0-fpm and php7.0-mysql work as expected.
It appears that the php7.0-* packages have been removed from the Ubuntu 15.04 version of the ppa:ondrej/php repo, but are available in the 15.10 version.
Currently upgrading all my servers based on this change.
Dave
The dotdeb repository seems to be working with the 7.0 extensions for me:
https://www.dotdeb.org/instructions/
It's probably not ideal, but:
"Depending on your distribution (Jessie, Wheezy or Squeeze), add these two lines to your /etc/apt/sources.list file (you can also choose a mirror near you) :"
deb http://packages.dotdeb.org jessie all
deb-src http://packages.dotdeb.org jessie all
Then you should be able to install everything with:
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv
I am trying to install php5-sqlite on Ubuntu 14.04, but this error occurs:
The following packages have unmet dependencies:
php5-sqlite : Depends: php5-common (= 5.5.9+dfsg-1ubuntu4.4) but 5.5.16+dfsg-1+deb.sury.org~precise+2 is to be installed
E: Unable to correct problems, you have held broken packages.
How do I resolve this error? I have upgraded my Ubuntu server from 12.04 to the current 14.04 previously.
I've met the same problem today. There are two ways to resolve it:
use aptitude to help you resolve all the dependency problems,
sudo aptitude install php5-sqlite
if you haven't install aptitude, install it:
sudo apt-get install aptitude
it will give you the option to downgrade the library file to an earlier version
download the proper version of php5-common (and related packages if necessary) from launchpad, use dpkg -i package to install it, then install php5-sqlite.
I highly recommend the second approach.
the accepted answer from #jfly didn't work for me, however, this answer helped resolve the issue by first uninstalling all the old php packages and then reinstalling them.
remove:
sudo apt-get remove php5 php5-common php5-mysql php5-xmlrpc php5-cgi php5-curl php5-gd php5-cli php5-fpm php-apc php-pear php5-dev php5-imap php5-mcrypt php5-sqlite
install:
sudo apt-get install php5 php5-mysql php-pear php5-gd php5-mcrypt php5-curl php5-sqlite
This means you have one source file not upgraded to the latest repo.
Either use apt-pinning to tell apt which source to prefere or make sure all your sources are up to date. You might need to do both :-)
Please also note that this question is rather off-topic on SO because 1. it doesn't involve programing 2. askubuntu.com is the stackexchange platform for ubuntu questions.