Can anyone help me install php-redis in MAC OSX .
brew install php-redis
not working.
pecl install php-redis
also not working getting -
invalid package name/package file "php-redis".
Homebrew Error:
homebrew_error
git clone https://www.github.com/phpredis/phpredis.git
cd phpredis
phpize && ./configure && make && sudo make install
Add extension=redis.so in your php.ini
brew services restart php#7.2
make test
You can check working or not
php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"
As of 2019, with homebrew php7.2 and up, pecl is now installed by default alongside the php binaries.
To see this for yourself type which pecl.
Steps to install
Check your version of redis, then find a suitable version of the extension here.
If unfamiliar with pecl, type pecl to see the options.
Issue pecl install redis-5.0.2. (or your version). Enter no to each question asked if you're not sure.
If that succeeds check the new file it created at: /usr/local/lib/php/pecl/20180731/redis.so
The install will have added extension="redis.so" to top of your php ini.
Check that by opening the file /usr/local/etc/php/7.3/php.ini.
(assuming you're on 7.3 there)
brew services restart php.
php -i | grep Redis
Redis Support => enabled
Redis Version => 5.0.2
This is what I just did in September 2019 and it works for me.
If what mwal wrote above doesn't work (please try his/her answer first),
first, try to uninstall first (if you have it but broken):
sudo pecl uninstall redis
and after that run:
sudo pecl install redis
After that, ini the php.ini, use full path for the extension.
Mine was /usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so (assuming you are using php#7.3)
so at the top of my php.ini file is like this:
extension="/usr/local/Cellar/php#7.3/7.3.21/pecl/20180731/redis.so"
Here are steps to use pickle, for PHP >= 7.3 (tested with 8.1):
brew install pickle
pickle install redis
Find your php.ini location via php -i|grep php.ini
Edit the php.ini, insert extension=redis. Preferable at Dynamic Extensions section.
No restart of Apache httpd service is required. You may test your PHP code with Redis
Bonus
If you use VS Code, to enable intellisense / auto complete, at Preference -> paste intelephense.stubs at Search setting box -> Add Item -> select redis.
If you got the following error,
Please make sure the PHP Redis extension is installed and enabled
despite doing everything in the verified answer above, try valet restart . It worked for me
I have tried all these solutions but didn't work for me for a while so I tried this link https://developer.redis.com/develop/php/ from the original docs and it works as charm
If someone gets an error during sudo pecl install redis
Warning: mkdir(): File exists in System.php on line 294
PHP Warning: mkdir(): File exists in /opt/homebrew/Cellar/-----/pear/System.php on line 294
that means you need to create the broken directory manually.
Try to create the directory...
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
# in my case, it was
mkdir -p /opt/homebrew/lib/php/pecl/20200930
Now try to install any pecl extensions.
sudo pecl install redis
After installing any extension, restart php
brew services restart php
Happy coding :)
Related
I changed my default apache server setup on my mac to be able of easily switching between php versions following this guide.
Now, when I return to my project which is based on the CMS TYPO3, I get the error, that "The PHP extension "apcu" must be installed and loaded in order to use the APCu backend.".
So I was following the tutorial (by the same author) to install and enable apcu.
I can sum up the installation process:
$ sphp 5.6
$ brew install autoconf
$ pecl channel-update pecl.php.net
$ pecl install apcu-4.0.11
This actually worked perfectly for php 5.6! But I wanted php 7.2 for my project. The tutorial instructs to do this:
$ sphp 7.2
$ pecl uninstall -r apcu
$ pecl install apcu
No errors here. But the CMS still claims no apcu! Searching for "apc" in phpinfo also returns in no results! Pecl added the extension="apcu.so" line in the loaded php 7.2 ini, so I don't understand what's wrong. Of course I restarted apache every time. Also no errors or warnings here.
Also after googling I have no idea what to do :/
You may try using an absolute path of the apcu.so in php.ini,
Like
extension="/usr/local/Cellar/php/7.3.2/pecl/20180731/apcu.so"
The path depends. Don't know why but this works for me anyway.
You may also need to check the following ini config entry for apcu:
apc.enabled=on
apc.enable_cli=on
How can I install intl PHP extension in PHP 7.1.7, which is delivered with osx high sierra?
So I had the exact same issue. As noted by other folks commenting here, High Sierra comes with PHP 7.1 installed and this PHP version has intl compiled with it
In my case, I followed part of Neodork comment's in the following Valet+ issue:
"Install" PHP 7.1 (so it comes from brew itself, not the one installed by High Sierra)
brew install php#7.1
Upgrade it to latest version
brew upgrade php#7.1
Symlinks for references in Cellar:
brew link --overwrite --force php#7.1
Change PHP path in my bash profile
echo 'export PATH="/usr/local/opt/php#7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.1/sbin:$PATH"' >> ~/.bash_profile
Reload your bash profile (you can close the terminal and open it again)
. ~/.bash_profile
Check for Intl
php -m | grep intl
Note: If you come across with warnings like:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-intl/intl.so'
Then you have to disable the previous intl:
mv /usr/local/etc/php/7.1/conf.d/ext-intl.ini /usr/local/etc/php/7.1/conf.d/ext-intl.ini.disabled
Hope it helps!
After the integration from brew/php to brew/core, the intl extension is included by the default installation. I also had the same problem the intl extension wasn't working. The problem I had was the command-line environment was not using the installed version of PHP but the default version from macOS system.
To enable the installed version, you need to do this:
After
brew install php#7.1
You need to link the installed PHP version by
brew link php#7.1
Then you need to OPEN A NEW TERMINAL to make it effective.
Then double check the PHP binary path,
which php
make sure it's
/usr/local/bin/php
instead of
/usr/bin/php
Then check if the intl extension is enabled,
php -m | grep intl
It works for me.
open a terminal then type:
brew search intl
you should be able to see php71-intl, then run
brew install homebrew/php/php71-intl
then restart apache
sudo apachectl restart
then type:
php -i | grep intl
you should be able to see something like this:
Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-intl.ini
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0
Enjoy!
I'm running the brew 1.6.2, on OS High Sierra. The intl extension is not available in brew packages so far.
The #Mondy solution worked fine for me. After run the
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
The packages will be available in /usr/local/php5 or /usr/local/php5-7.0.27-20180201-135220.
So in your /usr/local/etc/php/7.0/php.ini you can place the following lines to enable the intl extension:
[intl]
extension="/usr/local/php5/lib/php/extensions/no-debug-non-zts-20151012/intl.so"
In my case I prefered to create a file 'ext-intl.ini' in /usr/local/etc/php/7.0/conf.d/, just for a better organization.
try this on Mac
php -v
sudo port install php7*-intl
More information
You can find port packages by this page https://www.macports.org/ports.php?by=name&substr=intl
And you can install port through these steps: https://guide.macports.org/chunked/installing.macports.html
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.5.4.tar.bz2
tar xf MacPorts-2.5.4.tar.bz2
cd MacPorts-2.5.4/
./configure
make
sudo make install
And change ~/.bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
If there is error, check following steps:
check port
sudo port list
sudo port selfupdate
sudo port search --name --glob 'php*'
sudo port install php**-intl
This page has more info about port usage: https://guide.macports.org/chunked/using.html
In addition to what L. Grolleau says (run brew install php71-intl), paste the int.so path to the /php.ini at the end of the file:
extension=/usr/local/Cellar/php71-intl/7.1.11_20/intl.so
I find a solution.
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
Then I copied intl.so from the installation to my extension directory, which is defined into my php.ini.
I have managed to work this out.
First uninstall any php packages you have completely with brew, then run the brew update and brew doctor commands.
Now install with brew install php#7.1 (changed the version as needed) intl is included in the build for all php-formulae.
To confirm it is working run php -m | grep intl. You will see the intl extension is included. If not check the php.ini file and make sure the extension is being loaded.
Remove the following file with
rm /usr/local/etc/php/7.1/conf.d/ext-intl.ini
Worked for me, thanks to homebrew-core Issue
I installed php7.2 with brew and linked with that version on Mac, but cannot see even the version number 7.2 in phpinfo().
It always showed the last version(7.1) even though uninstall with brew, so the intl extension.
I found we have to modify httpd.conf file(in my case in /etc/apache2/httpd.conf), in that file you can find the
LoadModule php7_module libexec/apache2/libphp7.so
in that line you have to override with your new php72 path: in my case it was
LoadModule php7_module /usr/local/Cellar/php#7.2/7.2.31_1/lib/httpd/modules/libphp7.so
And restart apache, it works fine.
try this
brew install homebrew/php/php71-intl
I have successfully installed Laravel, but after running php artisan serve and going to localhost:8000 I get this error:
Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
I have checked phpinfo() on localhost:8888 and it says that mcrypt is properly installed. However the only thing I can think of is that maybe my path is wrong?
in my .bash_profile I have
PATH=/usr/local/bin:$PATH
Every time I try to run Laravel commands I have to type this in the terminal:
export PATH="~/.composer/vendor/bin:$PATH"
I am running on a Mac. Is there a simple way I can set up my bash_profile so that I can consistently change between localhost addresses and still have all the proper PHP functions working?
More simple way on ubuntu
apt-get install php5-mcrypt
mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
php5enmod mcrypt
service apache2 restart
Note: if you don't have "/etc/php5/conf.d" just skip that step and it will work ok
check http://php.net/manual/en/mcrypt.installation.php
This problem relative to the PHP extensions loader.
You no need to use laravel command at all after successful installation.
Laravel framework need Mcrypt Library for the security module and encrypt some of configure file.
The things that you need is theses steps.
Download Mcrypt http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
then configure make and install it.
Download php http://php.net/releases/index.php
Above 5.5.14 are suggested. (Use this path later on step 4)
then download Autoconfigure
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar xvfz autoconf-latest.tar.gz
cd autoconf-2.69/
./configure
make
sudo make install
then you have to go to directory level
cd ***YOURPHPDIRECTORY***/ext/mcrypt/
and run phpize within this directory level
/usr/bin/phpize
./configure
make
sudo make install
modify your php.ini to enable the mcrypt extension by insert this into php.ini
extension=mcrypt.so
Restart web server.
For Mac users's specially - install it using Home Brew
I’ve installed an empty Laravel installation and got the following error message when navigating to http://localhost/kanban/public/:
Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 – assumed ‘MCRYPT_RIJNDAEL_128′ in /Library/WebServer/Documents/xxx/config/app.php on line 83
Googling for this error message return many tutorials on how to install mcrypt on Mac OS X (whether building it from source or using Homebrew). The problem was that both the mcrypt and the php55-mcrypt packages were properly installed:
$ brew install mcrypt
Warning: mcrypt-2.6.8 already installed
$ brew install php55-mcrypt
Warning: php55-mcrypt-5.5.20 already installed
Mcrypt was also properly loaded by PHP:
$ php -m | grep mcrypt
mcrypt
$ php -i | grep mcrypt
Additional .ini files parsed => /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
for more details refer this link - http://benohead.com/mac-os-x-php-notice-use-undefined-constant-mcrypt_rijndael_128/
If you are seeing this on ubuntu or other flavors of *nix , it might help to do the following:
service php5-fpm restart
I just adjusted the .bash_profile in MacOS and it worked:
export PATH="/usr/local/sbin:$PATH"
PHP_AUTOCONF="/usr/local/bin/autoconf"
source ~/.bash_aliases
I also had this problem in trying to deploy a Laravel to Apache on Mac OS Sierra. I eventually found this post that gave step-by-step instructions to resolve this issue. These instructions assume that you have Homebrew installed; if you don't have it installed, then paste the following into a Terminal window to install it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Here is the relevant steps pasted from the post given above:
Step 1: Install autoconf and mcrypt
I used homebrew to install autoconf and mcrypt, which is as easy as:
brew install autoconf mcrypt
If this does not work for you, or you don't want to use homebrew, then check out this tutorial.
Step 2: Build the PHP extension
To build the PHP extension you will need the PHP 5.4.17 source code that is available for download here and extract it:
cd ~/Downloads
unzip PHP-5.4.17.zip
Then build the extension using the following commands:
cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make
sudo make install
Step 3: Enable the extension
All that is left is to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:
sudo cp /etc/php.ini.default /etc/php.ini
Edit the /etc/php.ini file and add the following:
extension=mcrypt.so
Step 4: Restart apache
Now just restart apache and you're done!
sudo apachectl restart
ADDITIONAL NOTES AND CLARIFICATION
I did encounter two issues with following these steps:
I had to match the PHP zip file that I downloaded to the version of PHP that was installed on my machine.
So I did
php -v
to determine the version number and then changed the download to match that version number. In my case the PHP version was 5.6.28 and so I needed to download the PHP source from
https://github.com/php/php-src/archive/PHP-5.6.28.zip
I got an exception at step 2 when I tried to do the sudo make install, the exception was caused by SIP, a security featured added by El Capitan. The exception is outlined in this question, and the resolution to this problem I found in this answer.
Applying the information from this answer changed the step 2 listed above and replaced the sudo make install with the following:
mkdir -p /usr/local/lib/php/extensions
sudo make EXTENSION_DIR='/usr/local/lib/php/extensions' install
Take note that because of this change, step 4 above also needs to changed to include the path to mcrypt.so. So the following must go in the php.ini:
extension=/usr/local/lib/php/extensions/mcrypt.so
I use nginx and php-fpm, and already did apt-get install php5-mcrypt, and moved the mcrypt.ini file to mods-available.
I had to do sudo service php5-fpm restart before it actually worked.
detailed instructions here https://www.php.net/manual/en/install.pecl.windows.php
make sure you choose appropriate extension version as of your PHP version
I had PHP 5.2 with MongoDB installed on Debian Lenny x64 and everything was fine.
After updating PHP to 5.3 (dotdeb) I can't get MongoDB to work, I always get an error
Fatal error: Class 'Mongo' not found (...)
Everything else works fine, all default modules are working.
My php.ini:
extension_dir = "/usr/lib/php5/20090626"
extension=mongo.so
Mongo.so is in same location as written above.
But when I run php -m in console to check loaded modules, "mongo" isn't listed there.
I can't use dl('mongo.so') to load module at runtime, because this function was deprecated in PHP 5.3.
May be I should recompile mongo somehow, I just don't know how to do that because I'm not very good in *nix commands.
Thanks for your help!
UPDATE
Also may be it's worth saying that before my mongo.so was in /usr/lib/php5/20060613 and I manually copied it to "/usr/lib/php5/20090626" because it seems that after updating my PHP all modules are located there.
The extension module api has changed between php5.2 and php5.3. When php tries to load an extension module both sides have to "present" an api magic key that identifies the api version. If those numbers don't match the module is not loaded/activated.
Try sudo pecl install mongo again to get an extension module that fits your new php version.
Try re installing mongo & restart service
sudo pecl uninstall mongo
sudo pecl install mongo
sudo service apache2 restart
This will install mongo in to newer version
I spent a little time trying to fix this, I am guessing you had a previous mongo install. The way I fixed it was by:
I installed php5-dev:
sudo apt-get install php5-dev
cd /etc/php5/apache2/conf.d/
sudo rm -rf mongo.ini
I then viewed my php.ini and removed extension=mongo.so
Then:
sudo pecl uninstall mongo
sudo pecl install mongo
sudo service apache2 restart
I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report.
I've gone into my php.ini file and added
extension=pgsql.so
But, I'm met with the following error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pg_connect() in... (blah file here)
When running phpinfo(), I see nothing about PostgreSQL, so what is my issue here?
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
Find your version of PHP: php -v.
Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
Type phpize.
Type ./configure.
Type make.
Type sudo make install.
Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
Type sudo chown -R $USER /usr/local/Cellar.
Type brew update.
Type brew install autoconf.
That should install autoconf and allow you to install the module using the instructions above.
If you use home brew, you can solve this with a command as simple as:
brew install php55-pdo-pgsql
for other php version, search with:
brew search pgsql
This worked for me with OSX 10.9.4 «Mavericks»
Install sources
Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:
tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP
cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module
I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:
cd ext/pdo_pgsql
In my case I had the following error:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. ERROR:
`phpize' failed
So I had to use this command:
brew install autoconf
Then:
phpize
After that I tried to do:
./configure
but I had the next problem:
checking for pg_config... not found configure: error: Cannot find
libpq-fe.h. Please specify correct PostgreSQL installation path
So the solution was to specify correct PostgreSQL installation path:
./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.
Then simply add
extension=pdo_pgsql.so to /etc/php.ini
Run php -m to confirm everything went to plan.
For those who installed php7/ngix/postgres with homebrew
You can install the PostgreSQL module with:
brew install php70-pdo-pgsql
After that, you have to restart the php service:
brew services restart php70
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
For php56 via brew:
brew install php56-pdo-pgsql
PostgreSQL by default is installed in a unusual place on MAC OS X:
/Library/PostgreSQL/9.3
Given the location above you can type this:
./configure --with-pgsql=/Library/PostgreSQL/9.3
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so.
Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.
For those of you having openssl error while make here is the solution
OSX uses openssl 0.98 while installer is searching for 1.0.0
refer this link for instructions
psycopg2 installation error - Library not loaded: libssl.dylib
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.
To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.