Mcrypt PHP extension required in Mac OS X El Capitan - php

Getting error Mcrypt PHP extension required. with Laravel in Mac OS X El Capitan.
Already installed the mcrypt using brew.
brew install mcrypt
brew install homebrew/php/php55-mcrypt
sudo apachectl restart
which php
/usr/local/bin/php
php --version
PHP 5.5.30 (cli) (built: Oct 3 2015 23:48:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
php --ini
Configuration File (php.ini) Path: /usr/local/etc/php/5.5
Loaded Configuration File: /usr/local/etc/php/5.5/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.5/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini

Yu most rename original libphp:
sudo mv /usr/libexec/apache2/libphp5.so /usr/libexec/apache2/libphp5.so.origin
and link the new homebrew php lib installed
sudo ln -s /usr/local/Cellar/php55/5.5.29/libexec/apache2/libphp5.so /usr/libexec/apache2/libphp5.so
and then restart apachectl
sudo apachectl restart
that works for me

I think this is what you are looking for:
http://phpbrew.github.io/phpbrew/
It lets you build any number of php versions, switch between them and set defaults. Add and remove extensions and more.
Good luck!

Related

How to enable PHP Intl extension on macOS Mojave?

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

how to add php5.6 mbstring extension in centos 6.8

My terminal shows php version as
[root#localhost modules]# php -v
PHP 5.6.25 (cli) (built: Oct 21 2016 17:57:17)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
and when I check for mbstring extension for php with php -m command I get
but when i check with yum list installed php* i get this
php-mbstring.x86_64 5.6.30-1.el6.remi #remi-php56
when I check with phpinfo() I get result as
1) i get related result in Additional ini file parsed section as
I try with new installation of php56w-mbstring also then also same problem.
Diagnostic
1/ find which php command is used:
which php
2/ find which package provides this command
rpm --query --file $(which php)
If this fails, this probably means you are using a manually installed PHP version, built from sources, usually in /usr/local.
Installation
As, in your case php is provided by rh-php56-php-cli, you need to install needed extensions, from the same repository (centos-sclo) and in the same namespace (rh-php56):
yum install rh-php56-php-mbstring
Its small mistake here...
In my setup there are two version for php
1)php with apahce and
2)php cli
[root#localhost modules]# which php
/opt/rh/rh-php56/root/usr/bin/php
[root#localhost modules]# find / -name php.ini
/opt/rh/rh-php56/register.content/etc/opt/rh/rh-php56/php.ini
/etc/opt/rh/rh-php56/php.ini
/etc/php.ini
here i select /etc/opt/rh/rh-php56/php.ini and after this check for mbstring in terminal by i fine mbstring.so file
as
[root#localhost modules]# find / -name mbstring.so
/usr/lib64/php/modules/mbstring.so
/usr/lib64/php-zts/modules/mbstring.so
with gedit /etc/opt/rh/rh-php56/php.ini i added that extension and related path with it as
extension=/usr/lib64/php/modules/mbstring.so
after that check with
php -m
now i get mbstring with this command.

php cgi error in PhpStorm when php-cgi is installed

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.

PHP Version in httpd phpinfo.php does not match the command line version

I have an installation of Fedora20. I have the Apache server and php packages installed using yum. When i run the command line:
php -version i get:
[root#host ~]# php -version
PHP 5.5.20 (cli) (built: Dec 18 2014 05:55:32)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
[root#host ~]#
however when i go to
http://host/phpinfo.php I get the following version:
PHP logo
PHP Version 5.5.10
I have run an md5 sum on libphp5.so and libphp5-zts.so.
[root#host modules]# md5sum libphp5.so
05687868a52f9f20960e8471fd10ebce libphp5.so
[root#host modules]# md5sum libphp5-zts.so
4a16156ba70db7e13cd6722618332c46 libphp5-zts.so
[root#host modules]#
I have compared them to an install that works fine and reports the version as the same for both apache and command line.
[root#host modules]# cd /etc/httpd/conf.modules.d/
[root#host conf.modules.d]# ls
00-base.conf 00-lua.conf 00-proxy.conf 00-systemd.conf 10-php.conf
00-dav.conf 00-mpm.conf 00-ssl.conf 01-cgi.conf README
[root#host conf.modules.d]# more 10-php.conf
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule !prefork.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
[root#host conf.modules.d]#
I have the run yum update as well.
I am at a complete loss as to where to look next. What am I missing? Any help would be greatly appreciated.
Here is an update: ran yum info php-cli
[root#host ~]# yum info php-cli
Loaded plugins: langpacks, refresh-packagekit
Installed Packages
Name : php-cli
Arch : x86_64
Version : 5.5.20
Release : 2.fc20
Size : 13 M
Repo : installed
From repo : updates
Summary : Command-line interface for PHP
URL : http://www.php.net/
License : PHP and Zend and BSD
Description : The php-cli package contains the command-line interface
: executing PHP scripts, /usr/bin/php, and the CGI interface.
It appears to be 5.5.20
There is a yum package called php-cli which is different from the standard php package apache uses.
Try $ yum info php-cli and see what it says. You may need to uninstall that and force install the desired version.

compile php 5.4.5 with mongo driver

Now I have installed php 5.3.* via apt-get on my Ubuntu PC, but I need to work with 5.4.5 for some issue.
According to this reason, I try to compile and install new version php 5.4.5 with mongo driver into separete place:
I did next steps:
sudo su
cd /opt
tar xfz php-5.4.5.tar.gz
cd php-5.4.5
./configure --prefix=/opt/php545 --enable-phar --with-config-file-path=/opt/php545/php.ini
make & make install
after above commands I had got working php:
/opt/php545/bin/php -v
PHP 5.4.5 (cli) (built: Aug 15 2012 09:04:56)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
after it I did next:
/opt/php545/bin/pecl install mongo
and it return me
Build process completed successfully
Installing '/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so'
install ok: channel://pecl.php.net/mongo-1.2.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongo.so" to php.ini
I added into /opt/php545/php.ini next line
extension=/opt/php545/lib/php/extensions/no-debug-non-zts-20100525/mongo.so
but mongo not loaded as module:
/opt/php545/bin/php -m | grep mongo
!!!Nothing here!!!
What did I do wrong?
PS:
/opt/php545/bin/php -i | grep php.ini
return
Configuration File (php.ini) Path => /opt/php545/php.ini
(php.ini seting up properly)
php config doesn't accept absolute path for extensions line, please use extension_dir.
Not load the extension from php.ini, load from ini file parsed as follows:
nano /usr/local/php-5.x.xx/php.d/mongo.ini
x.xx is you PHP version.
Then load the extension:
;Enable mongo extension module
extension=mongo.so
mongo.default_port=27017
save with ctrl + o and close white crtl + x
Then restart the services:
service php-fpm restart
service httpd restart
// php-fpm If it has
So you should already loaded.

Categories