when i run the the dockerfile on the server directly its working perfect and build the image but when i run it from jenkins it give me this error
Step 5/67 : RUN pecl install xdebug-3.0.4 && docker-php-ext-enable xdebug
---> Running in 111bf1524f04
downloading xdebug-3.0.4.tgz ...
Starting to download xdebug-3.0.4.tgz (215,870 bytes)
.............................................done: 215,870 bytes
87 source files, building
running: phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
building in /tmp/pear/temp/pear-build-defaultuser2CL8YH/xdebug-3.0.4
running: /tmp/pear/temp/xdebug/configure --with-php-config=/usr/local/bin/php-config
ls: cannot access '.': Operation not permitted
configure: error: working directory cannot be determined
ERROR: `/tmp/pear/temp/xdebug/configure --with-php-config=/usr/local/bin/php-config' failed
The command '/bin/sh -c pecl install xdebug-3.0.4 && docker-php-ext-enable xdebug' returned a non-zero code: 1
any ideas what is the problem
i run this step as root and still same problem
Ran into the same error yesterday. Have you tried using another image, e.g. php:7.4-fpm-buster (or cli)? I noticed that the images have been updated two days ago. Changing the image did the trick for me.
I just ran into your error too with various different commands. This appears to be a change introduced to the upstream dependency Moby which goes into Alpine Linux which goes into the PHP image.
Two solutions:
Short term: Pin your image to a previous version, e.g. php:7.3.28-apache (7.3.29 is broken on Docker 19 for me).
Long term: Upgrade Docker to 20.10.0+ AND libseccomp 2.4.4+ AND runc 1.0.0-rc93+ (read Alpine 3.14.0 release notes.
Sources:
https://github.com/docker-library/php/issues/1177
https://github.com/moby/moby/pull/41353
https://github.com/moby/moby/commit/a18139111d8a203bd211b0861c281ebe77daccd9
https://github.com/alpinelinux/docker-alpine/issues/182
https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.14.0
i removed docker and installed newer version and problem solved
I had same issue.
I could not build docker images based php7.4-fpm on docker in gitlab.
It resolved via updating docker engine to 20 from 19.
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 have php 7.4 installed on my macbook pro m1
% php -v
PHP 7.4.15 (cli) (built: Feb 26 2021 09:28:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies
I'm trying to install the mongodb driver running:
sudo pecl install mongodb
But fails after a while:
mp/pear/temp/mongodb/src/contrib/ -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/mongodb/php_phongo.c -fno-common -DPIC -o .libs/php_phongo.o
In file included from /private/tmp/pear/temp/mongodb/php_phongo.c:29:
In file included from /opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/spl/spl_iterators.h:24:
/opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/pcre/php_pcre.h:25:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
^~~~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed
I tried with
arch -x86_64 sudo pecl install mongodb
but results in the same error.
Somebody knows how can I solve this please? Or if I can install the mongodb driver without using pecl. Thanks in advance.
I have finally solved my problem.
I followed these steps from https://github.com/mongodb/mongo-php-driver/issues/1159
After installing a newer PHP version where previously I used 7.3.24 and updated to 7.4.16.
Still had the same issue but diffrent file:
fatal error: 'pcre2.h' file not found #include "pcre2.h"
From this error I tried to check the files in the MacOs Big Sur File system and in the end I found where the pcre2.h is located, and oddly it was being called in the pcre folder, so I manually copied from the pcre2 folder to pcre
The solution that I used:
$cp /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h /opt/homebrew/Cellar/php\#7.4/7.4.16/include/php/ext/pcre/pcre2.h
Then, I installed mongodb using
$brew install mongodb
After that, I once again tried
$sudo pecl install mongodb
Finally, it worked. However, I'm not sure if this is a good way to solve the problem by manually adding a header file to the directory.
(Sorry I'm still new to the MacOs Environment, just bought a mac mini m1 last week for developing my programming skills)
If you were to install php multiple versions from homebrew make sure you are using the current version as you wanted to. You could check the version by using which php.
To switch from 7.4 to 5.6
$brew unlink php#7.4
$brew link php#5.6 --force
credits: https://www.markhesketh.com/switching-multiple-php-versions-on-macos/
New error
Success Installation:
There is a simpler way to fix the installation issue than symlinking the header file into PHP sources. When running pecl install, you can provide additional compile arguments via the CFLAGS environment variable. So, on the Apple Silicon platform, you can use the following command to get the extension to compile:
CFLAGS=-I/opt/homebrew/include pecl install mongodb
Note that this is only necessary on Apple Silicon, not on x64. It also works for other extensions that fail because of similar errors (e.g. apcu)
I had the same issue with PHP 7.3, I solved it just by running the following commands:
cp /opt/homebrew/Cellar/pcre2/10.38/include/pcre2.h /opt/homebrew/Cellar/php#7.3/7.3.31/include/php/ext/pcre/pcre2.h
Then installed it successfully:
sudo pecl install mongodb
I have finally solved my problem. I used PHP 8.1.7 - Mac Pro 2022 - Apple Silicon (M1)
My errors: fatal error: 'pcre2.h' file not found
The solution that I used:
1. brew install pcre2
2. ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php/8.1.7/include/php/ext/pcre/pcre2.h
Please check your path again when use `ln -s`
3. sudo pecl install mongodb
See more: Install pecl pear on MacOs - Link
Success Installation:
Hope it help you :) Thanks
cp /Applications/MAMP/Library/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre/pcre2.h
then run
sudo pecl install mongodb
If you use MAMP,
Based on #Kelwin Tantono's answer follow instructions to install mongodb then,
Firstly, check for the location of pcre2.h file by
cd /opt/homebrew/Cellar/pcre2/
In this directory find the folder with ls command, in my case it was 10.40 .
Change 10.40 value in the below code with the result of ls command.
Then, check your php version with moving to php directory at MAMP by
cd /Applications/MAMP/bin/php/
Change php8.0.8 value in the below code with your desired php version.
cp /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre
Now you can install mongodb extension with below command after changing your working directory to
cd /Applications/MAMP/bin/php/php8.0.8/bin
sudo pecl install mongodb
Now, you should add extension=mongodb.so to php.ini file with
echo "extension=mongodb.so" > /Applications/MAMP/bin/php/php8.0.8/conf/php.ini
Do not forget to change php version.
I'm using Mojave OS X and I've been following these steps to install Xdebug through Pecl. I'm trying to set it up so I can use the debugger of PHPStorm.
http://www.devinbaldwin.com/2018/09/27/how-to-install-xdebug-on-a-new-mac-including-mojave/
This is my current setup:
Xdebug installed: no
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 7.3.6
Zend API nr: 320180731
PHP API nr: 20180731
Debug Build: no
Thread Safe Build: no
OPcache Loaded: yes
Configuration File Path: /usr/local/etc/php/7.3
Configuration File: /usr/local/etc/php/7.3/php.ini
Extensions directory: /usr/local/lib/php/pecl/20180731
I've followed all the steps but got stuck at installing Xdebug because I didn't have phpize.
I've installed the newest version of Xcode to create phpize, this worked at first, but I was having trouble appending the php.ini through PHPStorm because the file was read-only and I've thought of following another guide which talks about downgrading PHP to version 7.2 and installing Xdebug through that version, which is how this problem started.
When I tried to install Xdebug through Pecl, I've got this error.
downloading xdebug-2.7.2.tgz ...
Starting to download xdebug-2.7.2.tgz (230,987 bytes)
.................................................done: 230,987 bytes
69 source files, building
running: phpize7.2
sh: phpize7.2: command not found
ERROR: 'phpize' failed
At the sh, it never showed phpize7.2 before, it used to show phpize without the numbers.
I've tried to uninstall and reinstall homebrew and remove all php versions and installed the current php version as posted above.
I just want to know how I can revert phpsize to the current version. I've tried using PHP 7.2 but I still got the same error.
I've tried this guide since I'm using the latest PHP version, which is 7.3.
https://sys.cuquejo.org/install-php-7-3-xdebug-on-macos-mojave-with-homebrew/
But I still get the same error.
In addition, when I typed phpsize I got this:
Cannot find config.m4.
Make sure that you run '/usr/local/bin/phpize' in the top level
source directory of the module
However, when I typed phpsize --help
Usage: /usr/local/bin/phpize [--clean|--help|--version|-v]
Typing phpize72 --help would only show this:
-bash: phpize7.2: command not found
I'm not sure why this happened but any explanations could help.
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).
I think what I need to know is how to specify the build architecture when building .php extensions on OSX.
What are the likely architectures that I should try first, and how to specify them?
The details:
I am having trouble building a working mssql.so php extension for my server.
I have been using an AMPPS server on mac to serve php based websites, accessing MySQL databases.
Now I need to connect to an MSSQL database. The AMPPS php installation does not include the mssql extension so when I try to use mssql_connect() I get the following error.
Call to undefined function `mssql_connect()` in /Applications/AMPPS/www/test.php
I think I need to add mssql.so to the php/lib/extensions/ext folder and then add
extension=mssql.so
to my php.ini file.
To build mssql.so I have found a couple of online tutorials that both use Freetds:
http://lkrms.org/php-with-freetds-on-os-x-mavericks/#comment-82521
http://blog.benjaminwalters.net/?p=10
I used home brew to install autoconf:
brew instal autoconf
Then I downloaded and installed freetds:
./configure --prefix=/usr/local/freetds --sysconfdir=/usr/local/freetds/conf/freetds --disable-libiconv --disable-odbc
make
sudo make install
Freetds was installed at /usr/local/freetds. Then I downloaded php. I have tried this with all the versions available for download 5.6.2, 5.5.18, 5.4.32 and 5.3.29. 5.3.29 had a problem and I could not generate mssql.so.
All of the other versions successfuly produced mssql.so using the following method:
Unzip package in downloads folder
cd php-5.4.17/ext/mssql
phpize
./configure --with-php-config=/usr/bin/php-config --with-mssql=/usr/local/freetds
make
Then I copy the generated mssql.so to /Applications/AMPPS/php-5.4/lib/extensions/ext and add this to the php.ini file.
extension=mssql.so
I restart the apache server and view the error / log file which has the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/AMPPS/php-5.4/lib/extensions/ext/mssql.so' - dlopen(/Applications/AMPPS/php-5.4/lib/extensions/ext/mssql.so, 9): no suitable image found. Did find:\n\t/Applications/AMPPS/php-5.4/lib/extensions/ext/mssql.so: mach-o, but wrong architecture in Unknown on line 0
So it seems like I have built mssql.so for the wrong architecture?
I looked at the terminal output when I configure the "make" for mssql.so and found the following indicating the architecture it is being made for:
checking build system type... i386-apple-darwin13.1.0
checking host system type... i386-apple-darwin13.1.0
checking target system type... i386-apple-darwin13.1.0
So it looks like I made it for i386. This is where I start to get confused.
After make the terminal instructs me to run "make test", I do this and receive the following output:
=====================================================================
PHP : /usr/bin/php PHP_SAPI : cli PHP_VERSION : 5.4.24
ZEND_VERSION: 2.4.0 PHP_OS : Darwin - Darwin myMac13.1.0 Darwin
Kernel Version 13.1.0:
Thu Jan 16 19:40:37 PST 2014;
root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
INI actual : /Users/user/downloads/php-5.6.2/ext/mssql/tmp-php.ini More .INIs :
CWD : /Users/user/Downloads/php-5.6.2/ext/mssql Extra dirs :
VALGRIND:Notused
===================================================================TIME START 2014-10-26 11:53:50
=====================================================================
No tests were run. It does not say why no tests were run which is frustrating. It mentions x86_64 which is not i386.
I tried to check what architecture my system is to verify if it should be i386 or x86_64.
I did this with uname and arch as follows:
uname -p
i368
uname -m
x86_64
arch
i386
So my machine hardware is x86_64 (uname -m) but the processor architecture is i386 (uname -p) I don't understand how these can be different or what the implications of this are.
So have I built mssql.so for the wrong architecture or have I done something else wrong? If I have built it for the wrong architecture then how do I configure it to build for the correct one?
Many thanks for any help with this.