Just today I signed up with Google Cloud Compute Engine. I did everything but then I stuck into an error while installing php5-mcrypt extension.
Error:
root#instance-2:~# sudo apt-get install php5-mcrypt
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php5-mcrypt : Depends: phpapi-20121212
Depends: php5-common (= 5.5.24+dfsg-1+deb.sury.org~vivid+1) but 5.6.4+dfsg-4ubuntu6 is to be installed
E: Unable to correct problems, you have held broken packages.
I searched everywhere and then I came here. Please help.
sudo service apache2 restar
apt-get install php5-common
Or, if you dont need to keep configurations:
apt-get purge php5-common
apt-get install php5-common
Do you get any output from apt-mark showhold?
If it does not solve your problem, you should try install it with aptitude:
sudo apt-get install aptitude
sudo aptitude install php5-mcrypt
Finally reatast the server
sudo service apache2 restart
Had exactly the same problem. The accepted solution did not work for me. Took me eternities to figure a way.
sudo add-apt-repository -r ppa:ondrej/php5
sudo add-apt-repository -r ppa:ondrej/php5-oldstable
sudo add-apt-repository -r ppa:ondrej/php5-5.6
sudo apt-get purge php5* apache2* mcrypt*
sudo apt-get update
sudo apt-get upgrade
(WARNING: You'll lose all settings for your PHP and Apache installation!)
reinstall:
sudo apt-get install php5 php5-mcrypt php5-curl apache2
and enable the extensions
sudo php5enmod mcrypt
sudo php5enmod curl
Magic.
This is horrible, horrible, horrible. Adding ppa:ondrej/php5-5.6 together with ppa:ondrej/php5 and ppa:ondrej/php5-oldstable will bring you nothing at all, as you need exactly one of these (as one contains PHP 5.4, second PHP 5.5 and third PHP 5.6). Purging php5* and apache2* is also not necessary, you might want to purge apache2.2-common if you encounter an error upgrading, but that's it. And then mcrypt and curl modules will get enabled automatically (unless you have disabled them in the past), so php5enmod mcrypt and php5enmod curl is extra (but not harmful).
Related
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 want to install PHP5-Curl in my Debian server. But when I run this command:
apt-get install PHP5-Curl
I got an error like:
Reading package lists... Done
Building dependency tree
Reading state information... Done
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
E: Package 'PHP5-Curl' has no installation candidate
Use sudo apt-get install php5.6-curl
Try searching for the available version that suits for you with sudo apt-cache search curl | grep php and then sudo apt-get install php<x>-curl.
In my case it was php7.0-curl.
First search for your php version using command php -v and then download the respective version of php(version)-curl.
It looks like you have multiple, conflicting versions of PHP installed. First, let's clean up. Back up your configuration files first, as this will remove them.
dpkg --purge --force-all php5-curl
apt-get remove php5-*
apt-get purge php5-*
apt-get autoremove
Now, run dpkg -l | grep php5 again, and make sure that no php5-... packages are installed.
Then, let's start fresh:
apt-get install php5-cli php5-curl
If you need the Apache module:
apt-get install libapache2-mod-php5
Or if you need the FPM module:
apt-get install php5-fpm
I am trying to get the PDO_SQLITE extension because I have to read a SQLite database. I know I miss this module because I get the error message "could not find driver".
But when I try to install it through "sudo apt-get install php5-sqlite" it says I have a later version of it and cannot install it.
Anyone know how I can go around this problem? Even tried with aptitude and it just had one option which was to not install it.
This is probably due to some sort of problem with dependencies or a weird third party repository.
While I've never had an issue with this myself, doing a little bit of research shows that this might work.
$ apt-get --purge remove php*
$ sudo apt-get install php5 php5-sqlite php5-mysql
$ sudo apt-get install php-pear php-apc php5-curl
$ sudo apt-get autoremove
You'll of course want to backup any special configurations that you've put in place and keep note of all the php 'plugins' you need to have installed before doing this.
You can also try instead of purging all of everything that has to do with php, just doing sqlite
$ sudo apt-get --purge remove sqlite3
$ sudo apt-get --purge remove php5-sqlite
and trying to install them at this point.
I would also like to state that personally, I try to use apt-get as little as possible. I tend to use aptitude as it seems to have better dependency management. If you want to give that a go you can install it by: sudo apt-get install aptitude. It accepts most apt-get commands, and if you just type aptitude into your console it has a nifty console interface.
I'd like to know a basic run down of command line inputs to install Apache, PHP and a SQL database on a VPS.
I'm not sure if sudo apt-get install php5 is enough to install php5 while getting the dependencies such as gcc.
I'm looking at Debian (Wheezy) as that is what a friend of mine suggested. I'm testing different websocket/wamp router solutions probably alongside if not dependent on node.js eg. socket.io or crossbar.io.
sudo apt-get install mysql-server
sudo apt-get install apache
sudo apt-get install php5-common libapache2-mod-php5 php5-cli
There are additional instructions for installing the mysql-server:
http://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
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.