GRPC php extension Ubuntu 20.04 + Plesk - php

I installed grpc for a project using Ubuntu 20.04 with PLESK and SSH.
Installation is successful, before I run following commands:
apt-get -y install gcc make autoconf libc-dev pkg-config
apt-get -y install libgpgme11-dev apt-get -y install php-pear
apt-get -y install php-dev
cd /opt/plesk/php/8.0/bin
pecl install grpc
After installation the grpc.so file was stored under: /usr/lib/php/20190902/grpc.so
I manually copied it from there to the php plesk path:
cp /usr/lib/php/20190902/grpc.so /opt/plesk/php/8.0/lib/php/modules/grpc.so
Reread the php binaries
plesk bin php_handler --reread
Reboot the server (to make sure everything is restarted).
Under /opt/plesk/php/8.0/etc/php.d/grpc.ini the content is: extension=grpc.so
Then the extension is shown in plesk if I click on the php Version. I can activate the extension and deactivate it.
That comments in or out in the /opt/plesk/php/8.0/etc/php.d/grpc.ini
But in my php-code it is not working:
"Uncaught Google\Cloud\Core\Exception\GoogleException: The requested client requires the gRPC extension"
If I run:
/opt/plesk/php/8.0/bin/php -m | grep grpc
The output is:
PHP Warning: PHP Startup: grpc: Unable to initialize module
Module compiled with module API=20200930
PHP compiled with module API=20190902
These options need to match
In Windows with the precompiled .dll and XAMPP the code works fine.
phpinfo shows:
Additional .ini files parsed ---- /opt/plesk/php/8.0/etc/php.d/grpc.ini
But there is no extra section created and the extension is not loaded..

Related

php's ssh2 extension installation on RHEL8 with php 7.4

I have installed php7.4 via RHEL8's Default Stream using dnf.
I want to install the php's ssh2 module.
How do I install Pyrus (Pear2 Package Manager) on RHEL8 with php7.4?
When I tried: php pyrus.phar
I got the error message in command prompt: Could not open input file: pyrus.phar
I used:
updatedb
locate pyrus
Got nothing
So, what is the issue here?
Best Regards
Thayalan
I wanted to install php's ssh2 extension via Pyrus but I was having trouble with Pyrus. Therefore, I tried it without Pyrus. I preferred yum or dnf installation throughout. But, it was not possible for some. The following are how I have installed ssh2:
yum install make gcc php-devel php-pear
libssh2 package (ssh2 package needs it) installed by downloading the file https://libssh2.org/download/libssh2-1.10.0.tar.gz into an appropriate folder.
Then, I entered the following commands:
tar -zxvf libssh2-1.10.0.tar.gz
cd libssh2-1.10.0
./configure
make
make install
ssh2 package installed by downloading the file https://pecl.php.net/get/ssh2-1.3.1.tgz into an appropriate folder.
Then, I entered the following commands:
tar -zxvf ssh2-1.3.1.tgz
cd ssh2-1.3.1
phpize
./configure
make
make test
make install
Then I entered the following entry into /etc/php.ini: extension=ssh2.so
After that, I restarted php by: systemctl restart php-fpm
And now, php's ssh2 extension has been successfully installed.

Could not find driver ( PHP and Firebird )

I have a web-based PHP script named portail, so I want to make it functional on Ubuntu.
I installed Xampp 5.6 , Firebird 2.5 under Ubuntu, then I uncommented the library:
"extension=php_pdo_firebird.dll"
and I made the specific configuration for php5 and firebird
(https://mapopa.blogspot.com/2009/04/php5-and-firebird-pdo-on-ubuntu-hardy.html),
but he always shows me the following message
could not find driver localhost/portail
Screenshot:
You should install the required php extension if not already installed by default installation process. Php extensions are binaries which help php do extra things which can not without them. For example there is another well-known php extension called X-Debug which helps php developers debug their code.
First of all check that you have this php_pdo_firebird extension installed (or not), using Ubuntu CLI (Command-Line Interface):
installed system-wide by default:
php -m | grep -i pdo-firebird
installed using your package manager:
dpkg --get-selections | grep -i php-pdo-firebird
If none of the above returned a result, then you do not have that extension installed. you should install it using your preferred package manager:
sudo apt-get update -y
sudo apt-get install -y php-pdo-firebird
Try this
php -v
apt-get install -y php<your php version>-interbase

PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so'

I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does anyone knows how to deal it?
I am using php7.2
I faced similar issue when I installed Php7.2 on Ubuntu 18. Though I had installed mcrypt using PECL still I get the error mentioned in the question.
I did following to fix it
sudo apt-get install php-pear php7.2-dev
then uninstalled
pecl uninstall mcrypt
Now reinstall mcrypt
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
After success installing mcrypt using pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Now restart Apache
sudo service apache2 restart
Grab installing path and add to cli and apache2 php.ini configuration.
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
First, open up a terminal window and install the necessary dependencies with the commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
For (>= PHP 7.3) you can use the following command:
sudo pecl install mcrypt-1.0.2
I faced this problem when I upgraded my PHP to 7.3
I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
İts is worked for me.
export LC_ALL="C"
export LANG="C
sudo pecl install mcrypt-1.0.1
Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:
; extension=mcrypt.so
or just delete that line entirely.

Installing imagick on CentOS 7 with XAMPP and PHP 7

I have a local machine with Ubuntu, Apache 2.4 and PHP 7.0
I could install imagick easily using apt-get, but I can't seem to be able to do it on CentOS with XAMPP.
I tried many things including:
yum install php70w-pecl-imagick-devel.x86_64
pecl install imagick
Copying the imagick.so file to the modules directory
Adding extension=imagick.so to /opt/lampp/etc/php.ini and restarting
But the module simply isn't being loaded!
I keep on getting Class 'Imagick' not found in Laravel
Try with CMD or SSH or PuTTY
Once you have enabled the EPEL repository, install ImageMagick with dnf command.
dnf install -y ImageMagick ImageMagick-devel
PHP Imagick is a native PHP extension to create and modify bitmap images using the ImageMagick API.
dnf install -y php php-devel php-pear make
Now, install PHP Imagick with pecl command.
pecl install imagick
Please provide the prefix of Imagemagick installation [autodetect] :
just press Enter; do not type a prefix (that is, allow autodetect).
Add the extension into the php.ini file.
echo "extension=imagick.so" > /etc/php.d/20-imagick.ini
Restart the Apache web service to take an effect of newly installed PHP extension.
systemctl restart httpd
List the complied modules to see if PHP Imagick is installed and available.
php -m

install GNU PG (GPG) for php5.6 on ubuntu 16.04

I have 2 versions of php installed on my ubuntu php5.6 and php7. 5.6 is set as active version. Now I am trying to install GPG using below line of code, and it installs it under /etc/php/7.0 directory.
sudo apt-get install php-gnupg
How to install it for php5.6?
Extension dir for php 5.6 is /usr/lib/php/20131226 and extension dir for php 7.0 is /usr/lib/php/20151012 as this command shows:
php -r "print phpinfo();" | grep "extension_dir"
Pecl installs gnupg in /usr/lib/php/20131226/gnupg.so because the pecl was installed when php 5.6 is enabled
pecl list-files gnupg
Conclusion: PHP 7.0 uses a different extension directory than where the gnupg is installed.
First try which didn't work: Create symlink for gnup.so inside the php 7.0 extension directory that points to gnup.so inside php 5.6
sudo ln -s /usr/lib/php/20131226/gnupg.so /usr/lib/php/20151012/gnupg.so
Results in:
Warning: PHP Startup: gnupg: Unable to initialize module
Module compiled with module API=20131226
PHP compiled with module API=20151012
Second try which also didn't work:
Uninstall pecl extension: sudo pecl uninstall gnupg
Activate php v 7.0
Install gnupg again: sudo pecl install gnupg
Gives same compiling error.
Final solution:
Install a compiled version of the gnupg that works with php 7.0: see php docs here
Check if gnupg is installed
php -r 'var_dump(function_exists("gnupg_decrypt"));';

Categories