I am trying to install Imagick on my Mac, but I get this error after I use:
sudo pecl install imagick
ERROR: failed to mkdir /usr/include/php/ext/imagick
and here is the console log:
downloading imagick-3.4.3.tgz ...
Starting to download imagick-3.4.3.tgz (245,410 bytes)
...................................................done: 245,410 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Please provide the prefix of Imagemagick installation [autodetect] :
If I press return, then it keeps loading lots of things and then I get the error:
Build process completed successfully
Installing '/usr/include/php/ext/imagick/php_imagick_shared.h'
ERROR: failed to mkdir /usr/include/php/ext/imagick
Reboot Your Mac
Hold Cmd + R
Open terminal
csrutil disable
reboot
run
sudo pecl install imagick
add
extension=/usr/lib/php/extensions/no-debug-non-zts-XXXXXX/imagick.so
to your php.ini after your instalation is done
reboot your mac
Hold Cmd + R
Open terminal
csrutil enable
reboot
Here is the answer to your question:
Homebrew: install new formula php72-imagick
You may need to change the path for your modules. (read STEP 4 and 5 in particular).
Related
When I try to run the following command
pecl install imagick
Then the installation end up with:
imagemagick/7.0.11-9/lib -L/usr/local/Cellar/imagemagick/7.0.11-9/lib -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/imagick.so -bundle .libs/imagick_file.o .libs/imagick_class.o .libs/imagickdraw_class.o .libs/imagickpixel_class.o .libs/imagickpixeliterator_class.o .libs/imagick_helpers.o .libs/imagick.o .libs/imagickkernel_class.o .libs/shim_im6_to_im7.o -lgomp -L/usr/local/Cellar/imagemagick/7.0.11-9/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickWand-7.Q16HDRI.dylib -L/usr/local/Cellar/little-cms2/2.12/lib -L/usr/local/opt/freetype/lib -L/usr/local/Cellar/glib/2.68.1/lib -L/usr/local/opt/gettext/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickCore-7.Q16HDRI.dylib -Wl,-rpath -Wl,/usr/local/Cellar/imagemagick/7.0.11-9/lib
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imagick.la] Error 1
ERROR: `make' failed
The reason seems to be that the compilation of the last version of imagick (3.5.0) has changes that require this library. It's impossible to install a lower version because they are not compatible with PHP 8.0.
Any idea how to get rid of this error on macos?
Update 22 July 2021
As of 22 July 2021, version 3.5.1 is stable in the pecl channel and can be used to compile imagick for both PHP 7 and PHP 8.
pecl install imagick
The general command will not fail anymore
Old Answer
Version 3.5 currently can't compile on MAC because of missing/broken support for gomp of the MAC gcc compiler.
Best fix is to install version 3.4.4
pecl install imagick-3.4.4
More info here
There is a fix for this issue by manually installing the extension. The only issue with it is that it does not appear in the pecl installed extensions after the installation is done and can't be uninstalled from pecl. Nonetheless I'm providing the answer I found here:
Run the following commands
cd path/to/installation/is/going/to/be/made
pecl bundle imagick
cd imagick
mv config.m4 config.m4.bak
wget https://raw.githubusercontent.com/yyongpil/imagick/2a2b924b9d25c8ef4a677b72e6868fbc7c9e01cc/config.m4
To explain the previous process command line by command line:
Place yourself in the folder where you are going to make the install
Download and expand the source files
Enter the source folder
Backup the original config.m4 file for safety purposes
Download modified config.m4 file to fix gomp issue as explained here
And finally simply continue with the manual installation process
phpize
./configuration
make
sudo make install
After this, you should be good to go to use the latest imagick extension for PHP. For PHP 8.0 and imagick 3.5.0 the so file is located at /usr/local/lib/php/pecl/20200930/imagick.so
A new version has been tag and contains the build configuration fixed! You can install it with this command:
pecl install imagick-3.5.1
(without the version it should now work)
I am trying to install Xdebug on my Mac, since I am using MAMP for local development.
I tried using pecl to install Xdebug by running the following command in my terminal:
sudo pecl install xdebug
But the following happens:
hello-world:~ lois$ sudo pecl install xdebug
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.9.8.tgz ...
Starting to download xdebug-2.9.8.tgz (245,293 bytes)
...................................................done: 245,293 bytes
91 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
autom4te: need GNU m4 1.4 or later: /usr/bin/m4
ERROR: `phpize' failed
It looks like phpize is trying to locate some files which don't exist, and then fails.
There is no mention of those files in the xdebug installation page, so I am not sure what I did wrong.
Ok, so I finally found the solution to my problem.
First solution: if you are using MAMP
First, I am actually using MAMP for local development. If that is your case as well, you do not need to install Xdebug.
The reason is, Xdebug is already installed with MAMP.
There are only 2 things you need to do:
Modify the php.ini files in MAMP: https://dillieodigital.wordpress.com/2015/03/10/quick-tip-enabling-xdebug-in-mamp-for-osx/
Set up your IDE to use Xdebug. I am using VS Code, there are lots of tutorials on how to set up VS Code with Xdebug.
Second solution: you are not using MAMP, so you absolutely want to install Xdebug on your Mac
If you had the same problem I had with phpize, it is because newer versions of macOS have a different folder structure.
Xdebug expects a certain structure, which is not present anymore. In this case, take a look at this article: https://bbqsoftwares.com/blog/xdebug-catalina
Autoconf might be missing
run brew install autoconf and try again
on Apple M1 Silicon make sure to use arch -x86_64 sudo pecl install xdebug to install xdebug
I'm having trouble installing SPL_Types with pecl for MAMP 3.0.7.3. Note that I am NOT using the "Pro" version of MAMP. How can I install this, or any pecl package, for the basic version of MAMP?
When I run the pecl install pecl/SPL_Types command, the output is:
pecl install pecl/SPL_Types
downloading SPL_Types-0.4.0.tgz ...
Starting to download SPL_Types-0.4.0.tgz (8,388 bytes)
.....done: 8,388 bytes
6 source files, building
running: phpize
grep: /Applications/MAMP/bin/php/php5.6.2/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.6.2/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php/php5.6.2/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
I've read that with older versions of MAMP, there was an extra download available of "server components and libraries" that would supply the missing pieces. However, that appears not to be available any longer.
What is the correct procedure now?
It looks like you don't have autoconf installed. Try running this:
brew install autoconf
and see if that helps resolve the issue!
I am trying to build the memcached extension on OS X 10.9 Mavericks for use with the built in PHP 5.4, initially I tried pecl install memcached but that threw the following.
checking for zlib location... configure: error: memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB headers and library are located
ERROR: `/private/tmp/pear/install/memcached/configure' failed
So I created a tmp directory and executed pecl download memcached, unzipped the code and cd'd to the appropriate directory.
Trying to phpize it returned the following:
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
I had brew installed zlib a while ago and pointed ./configure at my installation.
./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8 I was greeted with the following error message:
checking for session includes... configure: error: Cannot find php_session.h
So now I'm wondering the best course of action here... /usr/include/ doesn't exist at all... is this a Mavericks thing? I don't remember having this problem in 10.8 at all.
I could try brew installing php-devel but I presume that isn't going to be the right version of what I need? Any help would be greatly appreciated here
Update
locate php_session.h reveals
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/php/ext/session/php_session.h
should I just ln -s this to the expected location or is there some way to do this via XCode? I have the command line tools installed...
run xcode-select --install to install the XCode5 Command Line Tools, then sudo pecl install memcache. You should be good to go.
After install XCode5 Command Line Tools as afessler sugest (xcode-select --install) I couldn't do the "sudo pecl install memcache" because pecl was missing.
I had to install PEAR and PECL following this guide: http://techtastico.com/post/como-instalar-pear-y-pecl-en-os-x-mavericks/.
Then all worked good. Thanks!
I had this problem and it was due to MAMP not having all the PHP sources.
I found this really helpful solution that explains how to download and configure them:
https://stackoverflow.com/a/11175197/369326
Note that the MAMP components doesn't include the extras for any versions of PHP higher than php 5.4.10 but you can download the extras from http://php.net/releases.
As said above but not using xcode install
Try installing pecl manually:
curl -O http://pear.php.net/go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar
and then:
sudo pecl install memcache
See more at: http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/#sthash.x2LKdqj6.dpuf
I installed the php redis extension. But when I run the test code, I got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/redio.so' - /usr/lib/php5/20090626+lfs/redio.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Class 'Redis' not found in /var/www/test/redisTest.php on line 2
My php version is 5.3.10, I installed the new version of phpredis.
May I get your help?
THANKS!
The install steps are:
git clone https://github.com/nicolasff/phpredis.git
cd phpredis
phpize
make
make install
Then add a config file in /etc/php5/fpm/confi.d to load redis.so
I use PHP 5.3 and installing PHP-Redis using below steps worked just fine for me:
Install pecl extensionsudo pecl install redis
In php.ini, you may need set extension_dir to correct value. (can be usr/lib64/php/modules as above command placed the redis.so in this directory). In my case, I didn't set this.
Add below line to php.ini:extension=redis.so
Restart Apache/PHP-FPM
To verify if you have got redis installed you can do this
php -m | grep redis
Create a file PHP with echo phpinfo(); in it and see if the module is showing up. If you do not see the module then it is not being loaded correctly.
In the PHP5.3 and Amazon Linux AMI (Same as Centos OS 5)
install libs
yum install php-pear php-devel make gcc wget
install redis
cd /opt/
mkdir /opt/redis
wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz "or last version"
tar -zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make
make install
install php-redis by pecl
pecl install redis
configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini
reload the web service httpd
service httpd reload
verify that the extension has been installed
php -m
[PHP Modules]
bz2
...
**redis**
...
[Zend Modules]
Download the proper library file according to your server environment( ex. x86). also, check for your PHP is thread-safe or not and download the Redis library accordingly. then place the library file inside the extension folder. you need to mention the library inside your php.ini as given below.
extension=redis.dll
then restart the server once, and check it's working properly or not.
if you have command line PHP, you can check it in the command line PHP as,
php r("print_r(get_loaded_extensions());")