I think this question is asked already, but with so many different conditions, I think my problem is a bit unique, correct me if I'm wrong.
I have this response after make a PHP update on my old MacBook. Using curl PHP install command:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
and this is my result after install and I check my version with "PHP -v" command on terminal
PHP Warning: PHP Startup: curl: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20180731
These options need to match
in Unknown on line 0
Warning: PHP Startup: curl: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20180731
These options need to match
in Unknown on line 0
etc
also in the end of the line there is this error:
Deprecated: Directive 'track_errors' is deprecated in Unknown on line 0
PHP 7.3.0beta3 (cli) (built: Sep 3 2018 11:26:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
PHP 7.3.0beta3 is my previous version.
Been tried to re-install the same version of PHP using command line but still doesn't work.
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3.0beta3
I know something un-match with the version. But how exactly I fix it.
I've been search the whole internet, and not found any solution that works well with me. Most question that I search here, is not marked as "worked solution" yet.
Probably I understand it wrong.
Anyone have the solution, please?!
I desperately need the answer. Thank you
FYI:
My MacOS is Yosemite 10.10.5
////////////////////
UPDATE 1:
I've been checked on this solution on THIS LINK
But it's not going to work since the solution require me to install PECL / PEAR, and that installer would work through PHP command. Which is broken for me.
////////////////////
UPDATE 2:
I've checked a shortcut file on 'usr/local/php5' and it's refer to a wrong directory, so I rename it to 'php5-old' and created a new alias from my old php directory and rename it 'php5'.
When I run 'php -v' command, it says a different error:
dyld: Library not loaded: /usr/local/php5/lib/libtidy-0.99.0.dylib
Referenced from: /usr/local/php5-7.3.0beta3-20180903-112811/bin/php
Reason: no suitable image found. Did find:
/usr/local/php5/lib/libtidy-0.99.0.dylib: stat() failed with errno=20
Trace/BPT trap: 5
I don't know what to do. I did check on that "libtidy-0.99.0.dylib" file, and still on the same directory.
////////////////////
UPDATE 3:
This is not the best practice. But I've got temporary solution already. I start to understand that the problem from my UPDATE 2 is from 'usr/local/php5', but instead I create a new alias that doesn't work, I rename the 'php5' refers directory and add "-old" prefix. And the original folder that should work "php5-7.3.0beta3-20180903-112811", I rename into the folder name that 'php5' alias refers to. And the PHP now working.
But still one more problem: "Apache web server" still not running.
So this problem looks like occur when my Mac itself has another problem (which I don't really know what it is).
So the best solution so far (been tried to avoid this from the beginning) is to create a new user and do install it all as a new laptop... And that's it. Works Normal
Related
I've looked around several other questions like this one, guide like this or this but I still had no luck.
Here's what i've done so far:
Downloaded gmp with brew using brew install autoconf gmp
Downloaded PHP (i'm using version 7.3.24) from source
Copied Gmp directory to /Applications/MAMP/bin/php/php7.3.24/include/php/ext
Entered that dir and launched phpize
Launched ./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.24/bin/php-config
Launched make
Launched make install
So far, so good. No errors, all seems fine but if i look at this point to my cli php -m (or php -i) there's no gmp extension loaded. So i went to my cli php.ini file and my web php.ini file and manually added extension=gmp.so (the file exist in this path /Applications/MAMP/bin/php/php7.3.24/include/php/ext/gmp/modules/gmp.so).
I even tried to specify the full path, but still no luck. Neither my cli or my phpinfo(); shows GMP enabled. I'm kinda confused atm and can't think about anything else.
What am I missing? Obviously, I restarted MAMP PRO like a dozen times, even my mac itself.
MacOs version: 11.4 Big Sur on iMac 24' M1
MAMP PRO Version: 6.3.1
PHP Version used: 7.3.24
Update 08/07/21
I updated MAMP PRO and it installed PHP version 7.3.27 so i went all over it again, download php from source https://github.com/php/php-src/releases?after=php-8.0.4RC1, copied ext/gmp into
/Applications/MAMP/bin/php/php7.3.27/include/php/ext, launched /Applications/MAMP/bin/php/php7.3.27/bin/phpize, ./configure --with-php-config=/Applications/MAMP/bin/php/php7.3.27/bin/php-config, make and make install. No errors.
Output of make install is:
Installing shared extensions: /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/
Installing header files: /Applications/MAMP/bin/php/php7.3.27/include/php/
shtool:install:Warning: source and destination are the same - skipped
I added extension=gmp.so to php.ini via MAMP interface, file, edit template -> php -> php7.3.27. Restarted MAMP and nothing new on phpinfo();
Update 12/07/21
As per Hakre request i've run the following command into cli and this is the result:
[~]$ php -n -d extension=gmp.so -i
PHP Warning: PHP Startup: Unable to load dynamic library 'gmp.so' (tried: /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture), /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so, 9): image not found)) in Unknown on line 0
phpinfo()
PHP Version => 7.3.27
which is quite interesting if you look at this img
The extension actually exists
For Raptor:
This is the output of the commands you've asked.
[~]$ which php
/Applications/MAMP/bin/php/php7.3.27/bin/php
[~]$ php --ini | grep "Loaded Configuration File"
Loaded Configuration File: /Applications/MAMP/bin/php/php7.3.27/conf/php.ini
[~]$ php --version
PHP 7.3.27 (cli) (built: Mar 16 2021 12:04:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
[~]$
Ofc there are multiple php's installed since MAMP alone fill it with like 4-5 version + there's the default one from MacOSx which i've overwrote with .zshrc bash profile
export PATH=/Applications/MAMP/bin/php/php7.3.27/bin:$PATH
That line is from my .zshrc
Could the issue be related to the new M1 chip? I'm using a new iMac bought just at the end of June2021.
Maybe is this related?
For Haridarshan:
Let me start saying that i tried to use .configure with no additional params, then i tried with CC="gcc -arch i386" CXX="g++ -arch i386" and even with CC="gcc -arch arm64" CXX="g++ -arch arm64" (i found arm64 in configure.log). None of them produced a valid .so, if i didn't miss any other info from the command line.
About the test u've asked me to make, this is the result:
[~]$ file /Applications/MAMP/bin/php/php7.3.27/bin/php
/Applications/MAMP/bin/php/php7.3.27/bin/php: Mach-O 64-bit executable x86_64
There can be many reasons why a PHP extension is not loaded, but it is not always easy to directly point to reasons (and fixes) as the distance between compiling from sources to showing phpinfo() and then finally missing the extension is large.
Get the real error message first
One way to reduce the distance in trouble-shooting is to see if the extension can be loaded by PHP and if not, showing an error message.
A common test for that is to use the CLI SAPI (PHP on the commandlineDocs) as it allows to reduce and easier control the PHP runtime environment while being compatible with the extension.
To start PHP with the default configuration (no .ini files), loading only the single extension binary to test and showing the configuration information, run:
$ php -n -d extension=gmp.so -i
Excerpt from OptionsDocs, also there is php --help:
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-i PHP information
This should provoke an error (shown in the terminal on standard error) or show the extension loaded in the PHP information output (on standard output).
Alternatively, to reduce the output and only check for the error, execute an empty PHP statement with the -r command-line switch:
-r <code> Run PHP <code> without using script tags <?..?>
The example with the GMP extension in question:
$ php -n -d extension=gmp.so -r ';'
This will exit non-zero (exit status) if there is a problem loading the extension displaying and error message on standard error and would exit with zero status in case the extension could be loaded:
$ php -n -d extension=gmp.so -r ';'
PHP Warning: PHP Startup: Unable to load dynamic library 'gmp.so' (tried: /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so, 9): no suitable image found. Did find:
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture
/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so: mach-o, but wrong architecture), /Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so (dlopen(/Applications/MAMP/bin/php/php7.3.27/lib/php/extensions/no-debug-non-zts-20180731/gmp.so.so, 9): image not found)) in Unknown on line 0
$ echo $?
254
As the example shows, the error is already in "PHP Startup" which is the typical phase where PHP signals diagnosis messages loading extensions.
Dlopen 9: no suitable image found: mach-o, but wrong architecture
The error message above shows that a) PHP is first of all unable to load the extension (as a dynamic library, .so file, a shared object file, that is the compiled extension) and b) that it failed to load as no suitable image was found:
PHP Warning: PHP Startup: Unable to load dynamic library 'gmp.so' (tried: <path> (dlopen(<path>, 9): no suitable image found. Did find: <path>: mach-o, but wrong architecture ...), <path>
(dlopen(<path>.so, 9): image not found)) in Unknown on line 0
That means the file is available on disk (can be opened) but the image is not suitable, which means it does not match the architecture.
(there is some noise in the try for gmp.so.so that is done by php so one can pass -d extension=gmp without the extension to work directly, e.g. in a php-.ini to work on both *nix (.so) or windows (.dll). This part can be ignored, that is "image not found" as the file does not exists which is expected)
It must be the same architecture as PHP itself as PHP is already running and wants to load the binary extension - they need to fit.
To get the architecture of PHP, locate the PHP command:
$ which php
/Applications/MAMP/bin/php/php7.3.27/bin/php
This is the absolute path to the php binary. With it, it is now possible with the file(1) utility to obtain more information about it:
$ file /Applications/MAMP/bin/php/php7.3.27/bin/php
/Applications/MAMP/bin/php/php7.3.27/bin/php: Mach-O 64-bit executable x86_64
(or call $ file "$(which php)" for running both at once)
It shows the php binaries info incl. the x86_64 architecture at the end:
Mach-O 64-bit executable x86_64
As the shared object image to load (the compiled php extension gmp.so file) also needs to match it, the same file(1) utility can be used on the compiled extensions .so file in the same manner.
The comparison then should show the difference.
With this information at hand finally the extension can be compiled with the appropriate architecture.
Closing notes:
On Apple Silicon M1 I'm not specifically profound of compiling and its architectures and others can tell it better. From what I've seen you manged it by running brew with the arch(1) utility setting the architecture by arch -x86_64 <command> to x86_64. On Apple Silicon this may require more tooling, namely Rosetta.
It seems to be something common M1 users blog about (via Austen Cameron in Nov 2020) but this is entirely not my system.
From my own understanding it should be possible to set the architecture with compiler flags or on the configure line and thats normally it.
As brew has the information how to compile an extension on a system (the brew formula, here for gmp) it is perhaps most straight forward to go with it and run the install under the correct architecture.
With the caveat that you need to start brew in (?) the correct architecture with the arch(1) utility as well (and the brew install).
Greeting developers, I want to learn laravel framework for my project. For that i follow some instruction in google to install it . i should have composer to install it. i try to download composer but there have some errors.the error is:
The PHP exe file you specified did not run correctly:
C:\xampp\php\php.exe
The php.ini used by your command-line PHP is:
C:\xampp\php\php.ini
A setting in your php.ini could be causing the problem: Either the 'extension_dir' value is incorrect or the dll does not exist.
Program Output:
PHP Warning: PHP Startup: Unable to load dynamic library 'php_mysql.dll' (tried: C:\xampp\php\ext\php_mysql.dll (The specified module could not be found.
), C:\xampp\php\ext\php_php_mysql.dll.dll (The specified module could not be found.
)) in Unknown on line 0
i try to resolve it. i check the php.ini file all looking good only. Is that because of i am using xampp server 7.2.0. I am really need a solution.
Turning the comment by ArtisticPhoenix into an answer.:
I would say the opposite, you need to remove it (comment it out with ;php_mysql.dll) from the php.ini. Because its been deprecated and "removed" in PHP7. Also just looking at what you posted C:\xampp\php\ext\php_php_mysql.dll.dll php_php_mysql.dll.dll ? seems weird. Double you fun, 2 php_ and dll extensions... lol
ArtisticPhoenix Sep 29 '18 at 7:54
I tested it successful.
So as the title describe, I am receiving this error right now on my CI after changing the PHP from 5.6 to 7.0. It works fine if I revert back to 5.6 but I need my server to be on 7.0.
A PHP Error was encountered
Severity: Core Warning
Message: PHP Startup: SourceGuardian: Unable to initialize module Module compiled with module API=20121212 PHP compiled with module API=20151012 These options need to match
Filename: Unknown
Line Number: 0
Backtrace:
From my 2013 blog post: https://delboy1978uk.wordpress.com/2013/10/30/manually-compiling-php-modules-successfully/
This look familiar?
PHP Warning: PHP Startup: memcached: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match
I don’t know about you, but i like to be up to date! My PHP is on 5.5, and I had to install some modules. But sometimes, old versions can rear their ugly head, and cause all manner of grief. Package managers do a good job to take care of all this for you, but sometimes they just don’t work. Leaving you to compile yourself! So lets do it! I’m going to install memcached, and then the imagick libraries (now i know what i’m doing!)
I’m doing this on a CentOS 6 server, but as we are doing the old skool way of compiling etc, this should work on any other flavour of Linux, or indeed Mac OS X.
First step is to download your .tar.gz then unzip it with tar -zxvf file.tar.gz and change into the folder.
Bring up a web page displaying your servers php.ini. You are looking for the version of PHP API, and the extension_dir.
In your terminal, cd into the module source code folder, and type phpize.
If when you check the API versions , they are different from your php.ini, then an old version of php is being used in the terminal, and your module will not work! In this case, you need to get it to use the correct phpize.
type which phpize to find out where the offending file is. (mine was /usr/bin/phpize)
My PHP appeared to be in /usr/local, so I tried running /usr/local/phpize. The API’s matched. So then I did the following:
mv /usr/bin/phpize /usr/bin/phpize-old
ln -s /usr/local/bin/phpize /usr/bin/phpize
Half way there! We need to do the same for php-config
mv /usr/bin/php-config /usr/bin/php-config-old
ln -s /usr/local/bin/php-config /usr/bin/php-config
Now you have done that, installation should be trivial, and work as per loads of tutorial/instrruction pages on the web.
./configure
make
make install
Finally edit your php.ini and add ‘extension = memcached.so’ (or whatever module you compiled), and restart your apache server!
EDIT : you may need to run ‘phpize –clean’ if it is still compiling with the older stuff from within the modules source folder
Download latest SourceGuardian module, which support PHP 7.X:
https://www.sourceguardian.com/loaders/download.php
Today I have migrated my XAMPP's internals to 64bit:
Apache (from 32bit 2.4.25 to 64bit 2.4.27)
PHP (from 32bit 7.1.4 to 64bit 7.1.9)
I have downloaded each extension used before in 32bit, installed, configured (copy&paste mostly with path changes if needed) and generally everything "works".
-> % php --version
PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
But somehow I get PHP Startup: Unable to load dynamic library errors even if there are valid DLLs (most of them bundled in downloaded PHP package). These are curl, intl, ldap and imagick (the last one is installed by me). Paths are correct in php.ini (many other extensions are loaded properly from the same directory). This is what I get in php_error_log every time when I access page through Apache:
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_curl.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_intl.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_ldap.dll' - The specified module could not be found.
in Unknown on line 0
[22-Sep-2017 15:52:47 UTC] PHP Warning: PHP Startup: Unable to load dynamic library 'D:\Bin\XAMPP\7.0.9\php\ext\php_imagick.dll' - The specified module could not be found.
in Unknown on line 0
In CLI everything is fine (it's the same php.ini as for Apache):
-> % php -i | grep -n3 curl
175:curl
178-cURL Information => 7.55.0
-> % php -i | grep -n3 ldap
347:ldap
349-LDAP Support => enabled
350-RCS Version => $Id: 0779387e5f88edc656159d12b9302a053e82cc79 $
-> % php -i | grep -n3 intl
330:intl
332-Internationalization support => enabled
333-version => 1.1.0
335-ICU Data version => 57.1
but in Apache I have Attempted to call function "curl_init" ... error :(
Any ideas?
I had the same problem on Windows 10 and solved it by adding the php home directory to the system (NOT user!) PATH environment and rebooting the system.
When Apache is installed as a service it is run as a system user which means it does not see your user environment variables.
it's basically 404'ing the dll's. either the user that apache runs as, doesn't have permissions to read the folder D:\Bin\XAMPP\7.0.9\php\ext\ , or the folder doesn't exist. as for why it works in cli but not in apache, they're probably reading different php.ini's , but it could also be that php-cli runs as a different user account. to check that, run php -r 'phpinfo();' | grep -i username in cli, and a page with <?php phpinfo(); and look for "Enviorment" > "User" in apache phpinfo(); , the pages will also tell you if they're loading the same php.ini file.
and nothing of this has anything to do with programming, so i say again, this should be on serverfault.com or something, not stackoverflow.com
Check if your DLL's are in proper version. There is quite often difference between x64 and x86 version, also between ZTS and NON TREAD SAFE. For some reason instead of nice error message of ddls being incompatible you will only get information: cannot load extension.
Well, this is weird but the root problem of this issue was... using Apache as service. I can't explain why, but when running Apache as service these extensions could not be loaded, but when running without service, using only "Start" from XAMPP control center, all is working fine with the same config and directory/file structure.
I realized that when I wanted to back to my previous working versions and I linked 32bit versions again (I use apache and php symlinks in XAMPP installation dir). cURL was not loaded, but it was working before migrating to 64bit. So I started digging and experiment with service and after unregistering it started working correctly. So I thought it could be the case with 64bit too... And it was.
Now I can start Apache properly. There is still minor issue because XAMPP control panel doesn't show Apache as running after clicking "Start", but processes are there and is working. But most important is everything is OK under the hood.
I had the same problem. All extensions loaded except these two: amqp and pdo_sqlite:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: D:\\xampp74\\php\\ext\\pdo_sqlite (The specified module could not be found.), D:\\xampp74\\php\\ext\\php_pdo_sqlite.dll (The specified module could not be found.)) in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'amqp' (tried: D:\\xampp74\\php\\ext\\amqp (The specified module could not be found.), D:\\xampp74\\php\\ext\\php_amqp.dll (The specified module could not be found.)) in Unknown on line 0
One solution is so add the php path to your environmental variable PATH.
The real problem here is that although extension dlls live in xampp\php\ext, some extensions have additional files that are located in xampp\php. These additional dlls are the ones that can not be loaded if the php path is not added to your PATH.
If you do not want to add the PHP path to your PATH, the solution is to add the extra dll files to the xampp\apache\bin folder (copy, not move). In my case:
libsqlite3.dll for pdo_sqlite
rabbitmq.4.dll and rabbitmq.4.pdb for php_amqp
Or, if you start apache via a batch file, add the php path before starting apache:
SET PATH=%PATH%;d:\xampp74\php
Okay, I've read the php.net docs, I've browsed numerous sites including stackoverflow for solutions and nothing has helped. So I'm asking, is there anyone who can post a definitive guide for getting enchant to work on Windows?
My set up is:
Windows 7
WAMP Server 2.0
PHP 5.3.0
PHP is located in
C:/wamp/bin/php/php5.3.0
I downloaded the php_enchant.dll from http://downloads.php.net/pierre/php_enchant-1.1.0-5.3-vc9-x86.zip and unzipped its contents. I did as the readme stated and
moved php_enchant.dll into C:/wamp/bin/php/php5.3.0/ext (my
extensions path)
moved all other dll files into C:/wamp/bin/php/php5.3.0
added extension=php_enchant.dll to my php.ini
restarted httpd
For dictionaries, I followed the first answer here PHP: Enchant Spell Checking not working. Configuration in Windows?
I downloaded the correct dictionary zips from Mozilla
I placed them inside of C:/wamp/bin/php/php5.3.0/share/myspell/dicts
After all of this trying to run
enchant_broker_init();
gives a fatal error. I really don't know what else to do. If anyone can give me some advice I'd really appreciate it.
Edit: Okay so my apache error log gives the following error
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.0/ext/php_enchant.dll' - The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.\r\n in Unknown on line 0 <b>Warning</b>: PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.0/ext/php_enchant.dll' - The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.in <b>Unknown</b> on line <b>0</b>[Wed Mar 05 15:28:02 2014] [notice] Child 6128: Child process is running
Pulling out my hair now.
Do you really mean WAMPServer 2.0?
That enchant was compiled with VC9, check that your PHP and Apache were also compiled with VC9, if not you need an enchant dll that was compiled with the same compiler as your Apache and PHP.
As you have PHP5.3.0 I would guess they are compiled with VC6.
Had the same problem. Add PHP path to Windows PATH variable and restart wampserver.