Setting Correct PATH for Homebrew PHP - php

I used Homebrew to install PHP versions 5.4 and 5.5 on my system. However, it seems that even after installing and linking to php55 my computer is still trying to run the version initially used by the system.
php --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_openssl.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_openssl.dll, 9): image not found in Unknown on line 0
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
I believe Homebrew sets up PHP under '/usr/local/lib' and not '/usr/lib/'.
What do I need to do to correctly have my system use the Homebrew version of PHP?

You have to put /usr/local/bin at the front of your $PATH. In your ~/.bashrc file, add something like
export PATH="$(brew --prefix)/bin:${PATH}"

Related

how to remove unused php versions from ubuntu?

Yesterday I tried to install php-gd for php7.2.15 on Ubuntu 18.04 lts. Today when Ubuntu got updated it installed php5.6 php7.0 php7.1 php7.3 beside my php7.2. I think I did something wrong but now I just don't want these versions on my server It's a server holding website and app so can't play with it, php -v now shows:
PHP Warning: PHP Startup: Unable to load dynamic library
'pdo_mysql.so' (tried: /usr/lib/php/20180731/pdo_mysql.so
(/usr/lib/php/20180731/pdo_mysql.so: undefined symbol:
pdo_parse_params), /usr/lib/php/20180731/pdo_mysql.so.so
(/usr/lib/php/20180731/pdo_mysql.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0 PHP
7.3.2-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:43:57) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.3.2, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.2-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
But phpinfo file is normal not mentioning anything irregular and everything is functioning like normal, but I'd like to keep my server clean so any advice?
Try to find the pdo_mysql.so file manually using find
Edit your php.ini file so it points to the right location of this file.
Most likely php mysql library got overwritten as a result of installation of multiple versions of php. Also make sure you are editing the right php.ini file.

PHP can not load Imagick library - PHP Startup: Unable to load dynamic library

I have High Sierra OS - Version 10.13.6
PHP Version: PHP 7.1.9
when I try to do command php -v always appear error like this:
PHP Startup: Unable to load dynamic library
'/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so'
- dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so,
9): Library not loaded:
/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from:
/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so
Reason: image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library
'/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so'
- dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so,
9): Library not loaded:
/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from:
/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so
Reason: image not found in Unknown on line 0 PHP 7.1.9 (cli) (built:
Sep 14 2017 10:05:35) ( NTS ) Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.9, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
AFAIK, my php.ini failed to load imagick library.
I already install Imagick with brew,
there is a file imagick.so inside folder /usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/.
I already search many sources for this issue, I found many similar issues too in StackOverflow, it seems similar to mine but still not fixed my issue.
I can still run PHP script obviously, but cannot do some manipulation image with Imagick.
Try:
sudo pecl uninstall imagick && sudo pecl install imagick
For debugging I suggest you move the dep to a folder easy to debug, such as in /User/<you>/Documents/. You can load it from the absolute path:
extention="/User/<you>/Documents/<project and check if it's a path issue.
I think that you are trying to install the dependency that is older than the current version of PHP, because you are loading the extention from php56 but you are using php71
https://stackoverflow.com/a/50529784/5893008

unable to download dynamic library

I want to install Composer on my Ubuntu 14.04LTS. But during installation I got this:
Some settings on your machine make composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The OpenSSL extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
Then in php.ini I remove semicolon';' in line ;extension=php_openssl.dll
After this I've got:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.6.2 (cli) (built: Oct 29 2014 06:55:23)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
Where can I get this library?
You use php.ini from windows machine. Use default from package manager. For Ubuntu apt-get.

PHP extension "mcrypt" must be loaded but no PHP source for my version?

I'm trying to install Magento but getting the error above. I've scoured the web for how to create the mcrypt extension (http://www.oldapps.com/php_programming_language.php?old_php=12364), but without luck because I can't find my version of PHP to install it (php 5.3.26).
I added mcrypt to the extensions list but now I just get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so, 9): image not found in Unknown on line 0
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
Scour the web for the source, try here: http://www.oldapps.com/php_programming_language.php?old_php=12364

sqlsrv running on php 5.4

I've just upgraded from PHP 5.3.10 to 5.4, now I get the following when trying to initialise php on the command line in windows:
C:\php5.4>php -v
PHP Warning: PHP Startup: sqlsrv: Unable to initialize module
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match
in Unknown on line 0
PHP 5.4.0 (cli) (built: Feb 29 2012 19:06:50)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
This should be a straight swap. I've downloaded the NTS version of php (same as 5.3.10 version) & referenced the php_sqlsrv_53_nts_vc9.dll (v2) of sqlsrv.
Out of interest I also have the sqlsrv v3.0 extension, which I tried to load in and get the same error.
Has anyone else had this issue, or know of how to fix it?
TIA
D
It looks like the version of the dll you have is for PHP 5.3
I'm not sure if there is a version out for 5.4 yet, but you can check the PHP Extensions for Windows page to see.
The system requirements page from Microsoft appears to indicate not (although it may not have been updated yet).
Only you need this link: https://www.microsoft.com/en-us/download/details.aspx?id=20098 the version 3.0
Regards

Categories