After the Yosemite update yesterday, something is messed up with the Mcrypt extension.
The PHP based artistan CLI of the Laravel framework returns:
Mcrypt PHP extension required.
The PATH variable seems to be correct. Where is the misconfig? Before the update everything worked fine.
++++ Configs ++++
Output of 'which php':
/Applications/MAMP/bin/php/php5.6.1/bin/php
'php -v':
PHP 5.6.1 (cli) (built: Oct 13 2014 18:41:35) Copyright (c) 1997-2014
The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend
Technologies
Content of .bash_profile:
export EDITOR=nano export
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/mysql/bin
export PATH=/Applications/MAMP/bin/php/php5.6.1/bin:$PATH
phpinfo():
MAMP PRO Version:
3.0.7.1
UPDATE:
Mamp-log says for every extension enabled in php.ini:
PHP Warning: PHP Startup: Unable to load dynamic library
'/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so'
- dlopen(/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so,
9): image not found in Unknown on line 0
I've contacted MAMP support, and this is what they responded.
Hi,
Our php.ini file is messed up for 5.6.1. Go to your template files and change this line
/Applications/MAMP/bin/php/php5.6.1 ....
to
/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20131226
We will have a full fix in a few days. You can also just downgrade to php 5.5. in the meantime.
I just had the same problem.
Just use PHP Version 5.5.17 in MAMP and everything should work fine again.
Remember to switch the version in your .bash_profile too:
export PATH=/Applications/MAMP/bin/php/php5.5.17/bin:$PATH
The hotfix was applied this morning MAMP & MAMP PRO 3.0.7.2 Published: 2014-10-21.
Default php 5.6.2
Don't forget to update .bash_profile
export PATH=/Applications/MAMP/bin/php/php5.6.2/bin:$PATH
Everything works fine on my local and it also works fine with drush (for those that use it)
the same error with you, but I perfect sloved it now:
Stop your MAMP
Open /Applications/MAMP/bin/php/php5.6.1/conf/php.ini
Find all "no-debug-non-zts-20121212" replace by "no-debug-non-zts-20131226"
Open /Applications/MAMP/bin/php/php5.6.1/conf/pear.conf
Find "no-debug-non-zts-20100525" replace by "no-debug-non-zts-20131226"
Start your server
I recommend you unistall OS X's default php and apache
Path:
/etc/apache2
/usr/include/apahce2
/usr/libexec/apache2
/usr/php
/usr/bin/php
/usr/bin/php-config
/usr/bin/phpize
/usr/include/php
/usr/lib/php
/usr/share/man/man*/php*
/usr/bin/phar.phar
then
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/pear /usr/bin/pear
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/peardev /usr/bin/peardev
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/pecl /usr/bin/pecl
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/phar.phar /usr/bin/phar.phar
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php /usr/bin/php
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php-cgi /usr/bin/php-cgi
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php-config /usr/bin/php-config
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/phpize /usr/bin/phpize
1) First check what php.ini file is loaded:
php --ini
You will probably see that none of the files have been loaded.
2) If you don't mind reinstalling php you can do this:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
3) Then set the path to your new php installation in order to avoid using the native php that comes with OSX.
In order to set the path use this command - something like this, bear in mind that your path could be different:
export PATH=/usr/local/php5/bin:$PATH
Related
I'm trying to install Magento (2.3.0) on macOS Mojave. Magento shows PHP Extension intl. is missing.
I tried the below to resolve:
Made a copy of php.ini using cp /etc/php.ini.default php.ini
Removed ";" before extension=php_intl.dll
Restart Apache sudo apachectl restart
But the above did not resolve.
On checking php -v, i'm seeing the below error:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll,
0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-
non-zts-20160303/php_intl.dll in Unknown on line 0
PHP 7.1.19 (cli) (built: Aug 17 2018 20:10:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
There are only 2 files under /usr/lib/php/extensions/no-debug-non-zts-20160303 namely opache.so and xdebug.so
How can i install or enable "PHP Extension intl" on my macOS Mojave?
Here's a solution that worked for me:
Find all PHP versions installed brew list | grep php
Remove all versions of PHP brew remove --ignore-dependencies --force php70 php71 php72 (based on what you see above)
Install PHP brew install php72 (i chose 7.2, 7.3 is not supported yet by several vendors)
Run the command which php should show you the path to the installed PHP. Copy the path.
Update your bash_profile vi ~/.bash_profile and add this line to the file:
export PATH=/usr/local/php5/bin:$PATH
Save and run this source ~/.bash_profile
Check if PHP Intl Extension is installed using php -m | grep intl. If the installation went well, we will see intl listed. If not the extension is not installed.
I think from PHP 7 (not sure of the version), the extensions are available by default and we need not enable them in php.ini file explicitly.
If you installed Homebrew's php, linking it to a directory in your path will fix the issue.
brew link --force php#7.3
I had the same issue and that fixed it.
Here is a link where I got a detailed answer from
Got help from the link and able to compile https://donatstudios.com/Install-PHP-Mcrypt-Extension-in-OS-X
Next we will download the PHP source. Verify the exact version of PHP you are running. This can be retrieved as follows. The version is highlighted.
$ php --version
PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Now we move into a working directory and download the source making sure to update the following for the version from above.
$ cd /tmp
$ curl -L http://php.net/get/php-{{php-version}}.tar.bz2/from/this/mirror > php.tar.bz2
$ open php.tar.bz2
Now we will compile and test the extension.
$ cd php-{{php-version}}/ext/{{extension}}
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
If all that goes well finally we'll need to add the following to our php.ini - I usually add at it at the end of the file.
extension = {{extension}}
.so
You can verify your installation with the following:
$ php --info | grep {{extension}}\\.
Lastly, depending on your setup now you may want to restart apache.
$ sudo apachectl restart
I have overlook at this issue Linux - PHP 7.0 and MSSQL (Microsoft SQL)
and I am sure did exactly what MS told me to do in this page
installing-the-drivers-on-red-hat-7
howevey, i stiil got the error when type 'php -v':
PHP Warning: PHP Startup: Unable to load dynamic library
'pdo_sqlsrv.so' (tried: /usr/lib64/php/modules/pdo_sqlsrv.so
(/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol:
php_pdo_register_driver), /usr/lib64/php/modules/pdo_sqlsrv.so.so
(/usr/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0
PHP 7.2.10
(cli) (built: Sep 15 2018 07:10:58) ( NTS ) Copyright (c) 1997-2018
The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend
Technologies
with Zend OPcache v7.2.10, Copyright (c) 1999-2018, by Zend
Technologies
I never modify the php.ini,
[user#tssvr php.d]$ pwd
/etc/php.d
[user#tssvr php.d]$ ls
20-sqlsrv.ini ctype.ini fileinfo.ini gmp.ini mbstring.ini pdo.ini shmop.ini tokenizer.ini xmlwriter.ini
30-pdo_sqlsrv.ini curl.ini ftp.ini iconv.ini mysqli.ini pdo_mysql.ini simplexml.ini xml.ini xsl.ini
bz2.ini dom.ini gd.ini intl.ini opcache-default.blacklist pdo_sqlite.ini sockets.ini xmlreader.ini zip.ini
calendar.ini exif.ini gettext.ini json.ini opcache.ini phar.ini sqlite3.ini xml_wddx.ini
[user#tssvr php.d]$ cat 20-sqlsrv.ini
extension=sqlsrv.so
[user#tssvr php.d]$ cat 30-pdo_sqlsrv.ini
extension=pdo_sqlsrv.so
it seems that the sqlsrv.so is good, but the pho_sqlsrv.so just can't work correctly,,although i notice that double 'so' appear: 'pdo_sqlsrv.so.so' ,
can any guys can help me through this ,many thanks.
Type in terminal linux centos 7 :
php --ini
find /etc/php.d/20-pdo.ini
Edit the file and append extension=sqlsrv.so extension=pdo_sqlsrv.so
note: comment extension extension=sqlsrv.so , extension=pdo_sqlsrv.so in /etc/php.ini
reboot system
php -m - you see loaded module
The proper order to load the modules is:
extension=pdo.so
extension=pdo_sqlsrv.so
extension=sqlsrv.so
One can either put these into one .ini file - or use numbered .ini files.
Loading them in alphabetical order (which is the default) won't work.
I ran into the same issue with Ubuntu 18.04 and 20.xx. I finally got it to work on Ubuntu 18.04 and pretty sure this will work on 20.xx as well.
This is for PHP 7.1 so if you are not using 7.4 or 8.0 you will have to specify the version in pecl.
pecl install sqlsrv-5.7.0preview
pecl install pdo_sqlsrv-5.7.0preview
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.1/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.1/mods-available/pdo_sqlsrv.ini
phpenmod -v 7.1 sqlsrv pdo_sqlsrv
service apache2 restart
The trick that got everything working was the printf and phpenmod command. You still need to add the extension to your php.ini file as well. Not sure if the order really matters but the driver does not appear to get installed properly using the pecl installer.
After restarting apache I can now see pdo_sqlsrv listed in php.ini and my php application can connect to the local Microsoft SQL server.
BTW, I got this working on WSL2 for Windows.
This is the way I solved this on CentOS 7.
First I've installed pdo_dblib extension
[root#localhost html]# yum list *dblib*
Complementos cargados:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirror.airenetworks.es
* centos-sclo-rh: mirror.airenetworks.es
* epel: ftp.uma.es
* extras: mirror.airenetworks.es
* remi-safe: mir01.syntis.net
* updates: mirror.tedra.es
Paquetes instalados
php73-php-pdo-dblib.x86_64
Paquetes disponibles
php70-php-pdo-dblib.x86_64
php71-php-pdo-dblib.x86_64
php72-php-pdo-dblib.x86_64
php74-pdo-dblib.x86_64
php74-php-pdo-dblib.x86_64
php80-php-pdo-dblib.x86_64
php81-php-pdo-dblib.x86_64
[root#localhost html]# yum install php73-php-pdo-dblib.x86_64
I have php 7.3 installed so I've chosen matching version extension. After installation, tried a simple test script I created to test connectivity but still got error.
Used locate command to find out if pdo_dblib.so library was correctly installed and found it under /opt/remi/php73/root/usr/lib64/php/modules path which looked a bit strange
With the command locate php.ini I discovered that there were 2 php.ini files on the machine. With the command php -i and by creating a simple file to test it from the web browser:
<?php
phpinfo()
I checked what php.ini file was in use both from Cli and from Apache. It was /etc/php.ini.
With php -m I saw PDO was loading correctly, so I searched the location of pdo.so library. Copied pdo_dblib.so library on previous search location. Searched for pdo_dblib.ini file and copied it under the location of pdo.ini file (which full name was 20-pdo.ini).
After all of these changes, restarted Apache systemctl restart httpd and checked again that pdo_dblib was loading both from cli and web whith php -i and the phpinfo() file.
I'm using Mac High Sierra. I installed PHP (with GMP) using
brew install php72-gmp
Everything installed successfully, per the messages given, but it would seem I still have an old version of PHP 7.1 somewhere on my machine because when I run
localhost:php-7.2.1 davea$ which php
/usr/bin/php
localhost:php-7.2.1 davea$ /usr/bin/php -v
PHP 7.1.7 (cli) (built: Jul 15 2017 18:08:09) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
So I'd like to figure out where to put the homebrew version of PHP ahead in my PATH so that that version gets picked up first.
EDIT:
As of 2018 and the latest updates to Brew your php formula names have the following format php#7.2.
When you run brew info php#7.2 your path should be /usr/local/Cellar/php#7.2/
And there will be a symbolic link to /usr/local/bin/opt/php#7.2/
So in order to change your php installation you just need to run this in terminal:
echo 'export PATH="/usr/local/opt/php#7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.2/sbin:$PATH"' >> ~/.bash_profile
or put it manually in your .bash_profile like this:
export PATH="/usr/local/opt/php#7.2/bin:$PATH"
export PATH="/usr/local/opt/php#7.2/sbin:$PATH"
===========================================================================
The location of your Homebrew installed php should be /usr/local/Cellar/php72
These are the steps you need to do to setup your PHP on macOS:
After you install php with brew run this in terminal:
export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"
Then run:
source ~/.bash_profile
To check your current active version of php run this in terminal:
which php
EDIT:
run brew info php72 in console to get all info, hints and caveats for php, it is really useful, for example this comes from brew info:
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the
following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent
configuration file:
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"
Check if you have two php directories in '/usr/bin/' or '/usr/local/bin/'. If yes do a link to the good directory. See this link, may be it helps you.
As you are familiar with linux, homebrew has its own /opt and /etc path
# > echo $(brew --prefix)
# /opt/homebrew
so the paths are (for Apple Silicon):
/opt/homebrew/opt
/opt/homebrew/etc
in linux, php is installed in /etc/php/7.4
in mac homebrew, php is installed in /opt/homebrew/etc/php/7.4.
Please find the homebrew document on the default installation path for Apple Silicon 1
ref 2
I am having a problem with PhpStorm (10.0.3) on OS X El Capitan throwing a php-cgi not found error on PHP 7 cgi/fastcgi. I tried the solutions offered in "How do I install php-cgi? I tried MacPort, Package and everything else but none works", but these did not work. I've consulted this: http://blog.jetbrains.com/phpstorm/2013/09/built-in-webserver-in-phpstorm/ but it is not helpful. I also tried a cgi install of PHP 5.6 but this has the same problem as PHP 7.
I have installed PHP70-cgi using macport and verified the install is cgi-fcgi:
$ php-cgi70 -v
PHP 7.0.2 (cgi-fcgi) (built: Jan 19 2016 16:48:28)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
When I try to use php-cgi70 from within PhpStorm it appears to incorrectly default to CLI:
PHP version: 7.0.2
PHP CLI: /opt/local/bin/php-cgi70 PHP CGI: Not Installed (php-cgi sapi is necessary to use built-in web server)
Loaded Configuration File: /opt/local/etc/php70/php.ini
I've also tried the macport install of php-fpm70, but this is not recognized by PhpStorm.
Does anyone have any ideas on resolving this? Thanks in advance.
PhpStorm can't find the PHP CGI binary. Do this on your shell to fix:
cd /opt/local/bin
sudo ln -s php-cgi70 php-cgi
sudo apt-get install php-xdebug
Another way for macOS is to install PHP all together with simple cURL:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
OR install Homebrew and then PHP with CGI (better practice):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install php72 --with-cgi --with-debug --with-libmysql
And link it in PhpStorm:
Image: PhpStorm: PHP Config
For more info about Homebrew, visit documentation here.
I would tring to update my php version to the version 5.5+ latest
When I'm looking via /usr/local/bin/php -v in the console I see the version 5.5+ and with php -v it tell me there is the version 5.4 installed.
How can I remove the older version 5.4 and install latest 5.5+ latest?
Typically I've used the PHP package from liip.ch
From terminal, run:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5
It will not remove the default installation of PHP 5.4 from your system, but it does not have any impact on using PHP 5.5. They address the issue with php -v in their FAQ.
Prerequisites
Xcode and it's Command line utilities (install form preferences) will give you a gcc compiler to build the php with libjpeg, libpng etc. if you want to build with these.
OR run this command on terminal to install Command line tools
xcode-select --install
Building and installing php:
Download the distribution from www.php.net/downloads.php
Untar the archive and point your console into the location
Now, having still the original old php installed, run php -i | head in the console. What you want is to configure your new php with these flags to ensure you have proper pcre support and everything works just fine.
In the php source directory you untarred, run the ./configure script with the flags you just got
Build php by running make and sudo make install afterwards. That will actually replace the original php distributed with OS X.
Example sample run terminal commands:
Download latest version from http://php.net and after ruin below commands
tar -zxvf php_scource.tar.gz
cd php_source/
php -i | head
./configure --prefix=/usr --with-snmp # ... same flags as previous build
make
sudo make install
end of the workflow for building php and just check latest version from terminal commands
$ php -v
sample output of php -v
PHP 5.5.10 (cli) (built: Mar 27 2014 16:50:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
OSX Mavericks runs PHP from /usr/bin/php so in order to run the new version that you want from /usr/local/bin/php, you need to copy this file over to the /usr/bin directory. If you want to save your old version of php, first go to the /usr/bin directory
cd /usr/bin
and rename your old php file
sudo mv php php.old
Then go to the /usr/bin/local directory:
cd /usr/local/bin
and then copy the php file over to /usr/bin using sudo:
sudo cp php /usr/bin
OSX Mavericks has /usr/bin first in its environment path, so the php in /usr/bin is found before it gets to the php in /usr/local/bin. Once you copy your new php file over, when you run
php -v
Which will display something like:
PHP 5.6.23 (cli) (built: Jun 24 2016 21:08:07)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
It will have your new version that was installed at /usr/local/bin/php that you copied over to /usr/bin/php instead of version 5.4. If you're running Apache and want your webserver to also use the new php version, you'll also need to update the httpd.conf file to point at the new php_module, but that's a different question.