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..
OS: macOS 11 (big sur)
Homebrew: 2.5.12
PEAR Version: 1.10.12
I just upgraded the php on my mac from php7.1 to php7.4 with homebrew (brew install php#7.4).
Then, when I try to install mcrypt extension, I got the error:
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
ERROR: `/private/tmp/pear/install/mcrypt/configure --with-php-config=/usr/local/homebrew/opt/php#7.4/bin/php-config --with-mcrypt' failed
Here is what I did:
brew isntall mcrypt
install the pecl
sudo pecl install mcrypt -- The error goes here.
What I tried:
Located the mcrypt.h and put manually the file to the several locations (based on the php-config), not work.
Cleaned the brew and reinstall/relink the mcrypt(libmcrypt), not work.
Removed the legacy mcrypt files of the old brew version.
I ran into the same problem. So after installing libmcrypt with brew install mcrypt it seems like configure is not able to resolve the path to mcrypt.h automatically. It also does not work to specify the CPPFLAGS or giving the homebrew include path.
But I found a solution that works for me by giving pecl the install location of mcrypt in the Homebrew Cellar. This is what the following code does automatically:
pecl install mcrypt <<<"$(ls -d $(brew --prefix)/Cellar/mcrypt/* | tail -1)"
if you using brew try this :
1.Unistall existing php then Install shivammathur/php
add shivammathur php
brew tap shivammathur/php
change php version with you needed (5.6 or 7.2 or 7.4 or 8.1 or next version)
brew install shivammathur/php/php#7.4
2.Install shivammathur/extensions it s will add extension to php
then
brew tap shivammathur/extensions
brew install shivammathur/extensions/mcrypt#7.4
then you install mcrypt with same version as php version
brew install mcrypt#7.4
then restart httpd
brew services restart httpd
Ref :
https://github.com/shivammathur/homebrew-php
https://github.com/shivammathur/homebrew-extensions
The problem here is the configure command can't find the libmcrypt installed by homebrew
You can
Download the source code of mcrypt-1.0.4, then cd in the folder
run "phpize"
run "./configure --with-mcrypt=/opt/homebrew/Cellar/mcrypt/2.6.8", you can change the path here with your path for homebrew lib
run "make && make install"
add extension=mcrypt.so to your config file
ps: Use php -i | grep "Loaded Configuration File" to locate your php configure file
in case of an error on macOS use the complete path in php.ini like:
extension="/opt/homebrew/Cellar/php/8.1.9/pecl/20210902/mcrypt.so"
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.
I have installed both php5.6 and php7.0 from PPA on Ubuntu according to this manual
http://lornajane.net/posts/2016/php-7-0-and-5-6-on-ubuntu
But I didn't get how to install extensions using pecl for php5.6 or php7.0.
For example I have already installed version of libevent or amqp in php5.6.
Now when I type pecl install libevent and my active php version is php7.0 (using update-alternatives --set php /usr/bin/php7.0),peclreturns message thatlibevent` already installed.
But it was installed only for php5.6 (when this version was active) and now I want to do it for php7.0.
Which commands could help me?
UPD
I have found this commands for switch pecl to php7.0 and packet them to executable bash scripts:
#!/bin/bash
sudo update-alternatives --set php /usr/bin/php7.0
sudo pecl config-set php_ini /etc/php/7.0/cli/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20151012/
sudo pecl config-set bin_dir /usr/bin/
sudo pecl config-set php_bin /usr/bin/php7.0
sudo pecl config-set php_suffix 7.0
and for php5.6
#!/bin/bash
sudo update-alternatives --set php /usr/bin/php5.6
sudo pecl config-set php_ini /etc/php/5.6/cli/php.ini
sudo pecl config-set ext_dir /usr/lib/php/20131226/
sudo pecl config-set bin_dir /usr/bin/
sudo pecl config-set php_bin /usr/bin/php5.6
sudo pecl config-set php_suffix 5.6
But they are not help, pecl still gives me list of already installed extensions to php5.6, even if I switched to php7.
pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
amqp 1.7.1 stable
libevent 0.1.0 beta
stats 1.0.3 stable
It should be empty for php7.0 !
How to solve the problem?
UPD
For amqp I have just installed php-amqp package without using pecl.
apt-get install php-amqp
And libevent still not exists for php7.
But I hadn't found a way to switch pecl installation between 5.6 and 7 version, so question is still open.
Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):
$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>
$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>
The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):
vagrant#homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages. More than one package may be
specified at once. Prefix with channel name to uninstall from a
channel not in your default channel (pecl.php.net)
Options:
...
-r, --register-only
do not remove files, only register the packages as not installed
...
The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).
When pecl throws error is already installed and is the same as the released version
Switch to required php, php-config, phpize versions before installing from pecl
Just run it installation with force flag
sudo pecl install -f <package-name>
I ran into this same issue while updating my Vagrant box with XHGui, as XHGui requires mongodb. I wanted to be able to support profiling on both PHP 5.6 and 7.0.
I dug into the pecl source code, and found that there's a metadata_dir config option. That is a path to a directory where the current state of installed packages. Unfortunately, that isn't already namespaced per PHP version. If you try and set it with pecl config-set, you get an opaque 'failed' error. It turns out that setting isn't whitelisted as being configuable in the \PEAR_Config class:
/**
* Configuration values that can be set for a channel
*
* All other configuration values can only have a global value
* #var array
* #access private
*/
var $_channelConfigInfo = array(
'php_dir', 'ext_dir', 'doc_dir', 'bin_dir', 'data_dir', 'cfg_dir',
'test_dir', 'www_dir', 'php_bin', 'php_prefix', 'php_suffix', 'username',
'password', 'verbose', 'preferred_state', 'umask', 'preferred_mirror', 'php_ini'
);
In PECL's world, 'global' means it can only be set at install time, and not after.
There's an issue in the PPA tracker over at github: https://github.com/oerdnj/deb.sury.org/issues/407
The final suggestion there is to build the extension manually for alternate PHP versions. I ended up using pecl for PHP 7 extensions, and manual builds for 5.6. Make sure you run update-alternatives for php-config and phpize, and not just php before building:
update-alternatives --set php /usr/bin/php5.6
update-alternatives --set php-config /usr/bin/php-config5.6
update-alternatives --set phpize /usr/bin/phpize5.6
Then, extract the extension and build it. These steps from the above issue worked for me with the mongodb extension:
phpize5.6 && ./configure --with-php-config=php-config5.6 && make && sudo make install
First of all, get admin permission in Linux Environment-
**Sudo su **
<>
Then follow below syntax
sudo apt-get install php7.3-bcmath
Here php7.3 (Enter your php version and check by php -v)
bcmath (Enter your extension name)
And if you want to check list of active extensions enter (php -m) in terminal.
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