How can I install imagick in current enabled PHP version? - php

I have multiple PHP version installed (7.0, 7.1 and 7.3). I have enabled PHP 7.0 (I need to keep this version for various reasons). When I try to install imagick (via sudo apt-get install php-imagick) the libraries are copied/installed only for PHP 7.3, despite I'm using 7.0 as confirmed by php -v and phpinfo file.
Am I missing any Apache setting? Why it doesn't consider the current 7.0 enabled module as default php version while installing new php libraries?
OS: Debian 10
WS: Apache/2.4.38
I've tried to edit php.ini, enable extensions, usual basic procedure... but imagick.so is compiled for php 7.3 only. There's no trace of them in the extension folder of PHP 7.0 and it's not possible to load it.
UPDATE #1
Checking with sudo update-alternatives --config php
I see this table (see image) - I don't know how to change priority or automode. It looks like PHP 7.3 keep the top priority.
screen
UPDATE #2
Tried this, no results.
PHP 7.0 set as default
sudo update-alternatives --set php /usr/bin/php7.0
sudo update-alternatives --set php-config /usr/bin/php-config7.0
sudo update-alternatives --set phpize /usr/bin/phpize7.0
Reinstall imagick
sudo apt-get install imagemagick php-imagick --reinstall
(no error, but it keeps installing them for PHP 7.3)
php -m show no modules, because they are in the extension folder of php 7.3

Debian 10 uses PHP 7.3 as its "standard" PHP version, so all of its PHP extension packages -- including php-imagick -- will contain extensions which target PHP 7.3.
If you have somehow installed PHP 7.0 (which you should not do, as it reached end-of-life in January 2019 and no longer receives security updates), you will need to obtain extensions for it through some other channel.

Related

how to upgrade from php 7.0 to php 7.3 on Debian 9.1

I have a Debian 9.1 droplet on DigitalOcean. 1GB Memory, 30GB Disk.
I've previously installed php 7.0 using
apt install php php-fpm
I also ran the following commands to install php modules:
apt-get install php-mysql
apt-get install php-curl
apt-get install php-zip
apt-get install php-apcu
apt-get install php-xml
How do I now upgrade from 7.0 to 7.3?
Just to give you an idea of how you can do it:
Basically, you need to follow two steps:
Install the 7.3 version as you did for 7.0 (you can pass the version number to install the exact version number)
You need to configure your PHP CLI to use the new version 7.3 instead of 7.0.
The above steps can be done for every version.
Here is documentation of how you can do it in case of migration from 7 to 8.
NOTE: The documentation will help you to install a version of PHP and configure CLI so you need to make sure to do the updates as per 7.3.
sudo-apt update
sudo apt-get install php-fpm
This will go try to update it if see you already have php-fpm...
Your repository should be updated to understand there is new version of php that is available for download
you can also remove & purge it and try to download it again...
but also consider some services needs to be updated and set to use last version of php that is currently installed...
Like Nginx ,in that you should update for .conf file to read php 7.3 or any installed versions
you can also check how many versions php do you have by going to directory by this command cd /etc/php and do ls

WARNING: Module mcrypt ini file doesn't exist, but is in installed

I run Ubuntu 16.04 and am trying to install mcrypt.
I can see it in my info.php.
I have followed this steps:
1. Install php7.0-mcrypt
sudo apt install php7.0-mcrypt
2.Create symbolic link to php7.0-mcrypt
sudo ln -s /etc/php/7.0/mods-available/mcrypt.ini /etc/php/7.0/mods-available/
3.Enable mcrypt extension
sudo phpenmod mcrypt
And when I enable I get this:
WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.2/mods-available
WARNING: Module mcrypt ini file doesn't exist under /etc/php/7.2/mods-available
But I don't use 7.2, I use 7.0 and I have the mcrypt ini file in /etc/php/7.0/mods-available.
The warning reports PHP version 7.2, so that's what is apparently running.
Are you sure you are running PHP-7.0? What does php -v returns?
I suspect you have multiple version of PHP installed on the system.
Try to run sudo update-alternatives --config php and choose the version that you want to work on.
That should fix it.

How to enable LDAP with PHP 7.0 in Ubuntu server?

I have recently upgraded Ubuntu to version 16.04 and PHP to version 7. However, the ldap connection is not working.
How to enable ldap in PHP 7?
To install ldap on a lamp with PHP version 7.0 (or 7.1):
apt-get install php7.0-ldap (or use apt-get install php7.1-ldap )
service apache2 restart
After that create a php file to get the php configuration phpinfo();
Now ldap is installed.
Providing the php version number is no more required:
apt-get install php-ldap
Is enough now, the correct package version will be automatically installed.
PS: Note that is it true if you use the standard php packages provided by your distribution. If you are using an additional ppa for PHP like the sury one, you will have to specify the version number as there are multiple versions available.
install both php ldap for your specific php version, mine was
sudo apt install php7.2-ldap php-ldap -y
it solves the problem i was having

An "issue" after ppa:ondrej/php5 deprecation

Today I was upgrading PHP 5.5 on my LEMP stack to version 5.5.35. After upgrading I received an on-screen message that the repo ppa:ondrej/php5 is deprecated and if I want to continue receiving php updates I should move onto ppa:ondrej/php which now includes PHP 5.5, PHP 5.6 and PHP 7.0 in one place. Previously these versions were in different repos.
I followed Ondřej's advice and I run:
sudo add-apt-repository ppa:ondrej/php
And then:
sudo apt-get update
sudo apt-get upgrade --show-upgraded
All went fine, except that two packages were held back: php-pear and pkg-php-tools. That of course happens from time to time when package dependencies change so I run:
sudo apt-get install php-pear pkg-php-tools
Then, I got a message that additionaly the following packages will be installed:
php-cli php-common php-xml php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline php7.0-xml
Immediately I felt that something is wrong here. Why the hell I need PHP 7.0 packages when I'm running PHP 5.5? However I went with option YES and apparently everything went fine. The server is running, no errors or confilcts that I'm aware of. Then I was curious and I checked what version of PHP am I running?
php -v
The output was:
PHP 7.0.6-1+donate.sury.org~trusty...
What the hell happened here? How did I ended up installing PHP 7.0 and why the server/site isn't crashing? Since I use nginx with php-fpm, by examining the nginx.conf I can clearly see that nginx is pointing to php5-fpm.sock so I definitely run php5-fpm here. Plus the site is up, and there are no PHP errors in the log.
I also went and I've uploaded a phpinfo file. The file shows I'm using PHP 5.5.35. So there are two conflicting messages where command via ssh shows that the PHP version is 7.0.6, while the phpinfo file shows that the server is using PHP 5.5.35.
So I run:
sudo apt-get remove php7.0-common
All previously added php7.0 packages were removed and also those two that were initially being held back.
Now, after checking the PHP version via SSH it showed correctly 5.5.35. While all this was happening the server had no trouble whatsoever. The status at this moment is that I don't have php-pear and pkg-php-tools packages, but if I try to install them all those php7.0 packages will have to be installed too.
I've also examined /etc/php5 and /etc/php folders. In this second folder there is 7.0 folder where cli and mods-available folders with mods inside reside.
Can someone explain to me what is happening here and what should I do? Are php5 and php7.0 simultaneously running on the server? Do I need those two packages that were held back in LEMP + Wordpress stack?
php-pear and pkg-php-tools must depend on PHP CLI for default PHP version and that's PHP 7.0. Installing php-cli pulls php7.0-cli that will install /usr/bin/php7.0 and registers it as alternative with highest (70) priority to provide /usr/bin/php.
Installing PHP CLI binary is mostly harmless unless you need to run PHP scripts locally using command line. I could recommend two approaches:
Rewriting those scripts to specify required version, e.g. changing php <script> to php5.6 <script>, or
Use update-alternatives to switch /usr/bin/php to your desired PHP version: a) switch to specific version update-alternatives --set php /usr/bin/php5.6 or b) update-alternatives --config php configure the version by hand
More thorough version of the migration guide is located in DEB.SURY.ORG Wiki.
To use the new PHP FPM packages, you need to install:
sudo apt-get install php5.5-fpm # for PHP 5.5
sudo apt-get install php5.6-fpm # for PHP 5.6
sudo apt-get install php7.0-fpm # for PHP 7.0
and adjust the socket accordingly, look into default FPM configuration:
sudo editor /etc/php/X.Y/fpm/pool.d/www.conf
for the socket location (it's /run/php/phpX.Y-fpm.sock by default).

How do I install mcrypt for lampp in ubuntu 14.04 lts

I am new in php framework. So, I am trying to grasp the pros and cons of Laravel 4.2.11
But when I was going to install composer in the laravel's root folder in the htdocs folder of lampp, it showed warning in the terminal that it requires MCrypt PHP Extension.
By the way, I have another php installed in my PC in /usr/bin/php and its version is 5.5.9 and Lampp's php version is 5.6.12
phpinfo() of Lampp showed that It has mcrypt support and mcrypt_filter support, both are enabled.
What should I do to enable artisan to work for Lampp's php?
First ensure the mcrypt module is installed:
sudo apt-get install php5-mcrypt
Then:
sudo php5enmod mcrypt

Categories