简体   繁体   中英

Install grpc extension on Mac OS Big Sur

For 2 days now, I am trying to install grpc for php on my Mac mini server

  • Mac OS Big Sur 11.2.1
  • Built-in Apache
  • I have tried it on php 7.3 and 7.4 installed with homebrew

I have installed grpc pecl grpc install after a bunch of attempt I have finally compile and installed it with pecl.

extensions are placed in the good repertory. But I encounter signing issue. php -m show grpc in the list but not php_info()

PHP Warning: PHP Startup: Unable to load dynamic library 'grpc.so' (tried: /usr/local/lib/php/pecl/20190902/grpc.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so, 9): no suitable image found. Did find:\n\t/usr/local/lib/php/pecl/20190902/grpc.so: code signature in (/usr/local/lib/php/pecl/20190902/grpc.so) not valid for use in process using Library Validation: mapping process is a platform binary, but mapped file is not\n\t/usr/local/lib/php/pecl/20190902/grpc.so: stat() failed with errno=1), /usr/local/lib/php/pecl/20190902/grpc.so.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so.so, 9): image not found)) in Unknown on line 0

  1. I have disabled SIP. Still same issue.
  2. I have codesigned the extension with my apple developper ID. codesign -f -s "Mac Developer: MY_DEV_ID" /usr/local/lib/php/pecl/20190902/grpc.so same issue
  3. I have xattr /usr/local/lib/php/pecl/20190902/grpc.so then sudo xattr -d com.apple.quarantine /usr/local/lib/php/pecl/20190902/grpc.so
  4. I also tried with gatekeeper disabled.

And still the same problem. Is there someone that sucssefully installed grpc on the Mac with Big Sur, who would have an idea on what is going wrong?

I experienced the same thing, I have tried several times to install it and I just solved the problem.

In my case when running

sudo pecl grpc install

there was an error in the installation process with error information like

ERROR: failed to mkdir /usr/local/Cellar/php@7.4/7.4.15/pecl/20190902

see in the picture: running pecl grpc install

The problem is that the installation process can't create a new directory for /usr/local/Cellar/php@7.4/7.4.15/pecl/20190902, so I tried to create that directory first by running the command:

mkdir /usr/local/Cellar/php@7.4/7.4.15/pecl/

Then run the installation process again and and it worked!

1. See Cellar/php/... directory:

for me:

看目录

for you:

ls -la /usr/local/Cellar/php/YOUR_PHP_VERSION/

2. See the directory "pecl" which is a link:

在此处输入图像描述

3. Check the link:

ls -la /usr/local/lib/php/pecl

if:

No such file or directory

execute:

mkdir -p /usr/local/lib/php/pecl

sudo chmod 777 /usr/local/lib/php/pecl/

4. Reinstall extension:

pecl install grpc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM