memcache won't appear php with osx homebrew - php

I have php project I want to develop in osx and I have used memcache
I have implemented in linux but when I try to migrate to osx i can't find memcache
I have tried to install it with brew or pecl doesn't work
I have tried xampp as well and doesn't work
Sure I have done
sudo apachectl restart
added memcache.co to php.ini
I use php 5.6 and php 7.0 and just note I use memcache not memcached

It should be installed with PECL:
pecl install memcache
locate the php.ini file:
php --ini
then edit the php.ini file and add the complete path to memcache.so (as shown at the end of the installation output)

Related

Enable MCrypt using MAMP

I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:
php -m | grep mcrypt
output: mcrypt
I can locate the library but it doesn't seem to be enabled.
That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.
Although it may just be enabled for CLI.
You can try editing the PHP.ini file and adding the following line under the ; Extensions section:
extension=mcrypt.so
Restart Apache / MAMP after saving php.ini file.
To find the correct php.ini file to edit, run the following command line:
php --info | grep php.ini
(If the line already exists, you may just need to remove the ; thats in front of it.)
I have tried so many ways but had no luck.
After a lot of trials finally came up with a solution.
Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin
It might be different in your case. Now run the below command with sudo
sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1
Now You should add extension=mcrypt.so to php.ini
Restart MAMP Service and check if it is working.
I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...
The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.
The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)
Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line
Added to .bash_profile
alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'
try in console
pecl install mcrypt
Using Brew:
Install mcrypt: brew install mcrypt
In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):
extension=mcrypt.so
Save, restart and test (with php -i | grep mcrypt for example)

PHP-5 mcrypt won't enable on nginx server ubuntu 14.04

I've been trying to install mcrypt extension for php5 on Ubuntu 14.04 ARM server running nginx.
PROBLEM
In phpinfo() I can only see the authors of mcrypt but the module itself is missing. I can't use mcrypt functionalities anywhere on that server.
WHAT I TRIED
Running php5 -m shows that mcrypt is installed.
In /etc/php5/fpm/php.ini I have the following extension = /usr/lib/php5/20121212+lfs/mcrypt.so. This I read in google after I tried only with extension = mcrypt.so. Neither gave result.
In /etc/php5/fpm/conf.d/20-mcrypt.ini I have this extension=/usr/lib/php5/20121212+lfs/mcrypt.so as well.
I restarted php5-fpm and nginx multiple times, I also tried php5enmod mcrypt which doesn't show any warnings or errors.
I created symlink between the .so and .ini file.
Any ideas?
Ok so it turns out that my only escape was to purge php5-fpm, reboot the server, then apt-get install php5-fpm, now everything is loaded correctly. I have no idea why this happens. If anyone has explaination I'll be happy to update my answer with it.

Enable XSL on Ubuntu 12.04

I am trying to enable XSL on Ubuntu 12.04 but its failing. I did this locally on my Ubuntu 13.04 and it was successful. Basically the following worked on my local computer.
apt-get install php5_xsl
edit php.ini file and add extension=php5_xsl.so
restart apache
I repeated the same procedures on my production server running Ubuntu 12.04 and PHP version 5.5.12 but the extension is not getting loaded from the phpinfo. I have also changed the extension=php5_xsl.so to extension=xsl.so because this is what in the extension directory.
I read that I might need to recompile PHP but I am not sure of this steps.
Try this:
sudo apt-get install php5-xsl
sudo php5enmod xsl
sudo service apache2 restart
Why:
http://www.lornajane.net/posts/2012/managing-php-5-4-extensions-on-ubuntu
What's happened here is that all debian-flavoured unixes have adopted
this standard for their PHP 5.4 packages, so if you're using debian,
ubuntu, or any of their relatives with PHP 5.4, you'll see a directory
structure like this. When you add a module to PHP, you'll add a file
to the mods-available directory enabling the module and adding any
config specific to it. If you want to enable the module, just do:
php5enmod http
This simply creates a symlink from the usual conf.d directory to point
to where the real files are in mods-available, prefixed with a number
that indicates the priority of the module. By default, the priority is
20.
Using this approach means we can toggle things on and off without
commenting out big chunks of config files and leaving them lying
around - if this seems familiar then that's no surprise; debian-like
linuxes manage their apache configuration in just the same way. Any
packages that you install using aptitude will use these exact same
commands to set up the configuration and then symlink it correctly. To
unlink, use the delightfully predictably-named php5dismod :)

can't find mcrypt => Call to undefined function Laravel\mcrypt_create_iv()

Trying to set up Laravel and keep getting hit with this error. I installed mcrypt through brew and it is located in /usr/local/Cellar. Any thoughts? .. It's not showing up in terminal command php -m either, if that matters. I'm running Mountaion Lion with macs native web server.
Ubuntu or any Debian based Linux users can install the required package with apt-get:
sudo apt-get install php5-mcrypt
Remember to restart the web server afterwards:
sudo service apache2 restart
If it still doesn't work, try to link the configuration file to the appropriate configuration folder for the web server. Thanks to dave1010 for this hint in the comments.
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/ # for Apache
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/ # for CLI
And again, restart the web server:
sudo service apache2 restart
Perhaps, if not working yet, you need also the line showed by #RahulPrasad, with php5enmod mcrypt.
You need to enable it in your php.ini file as well and probably restart Apache.
In php.ini you will find ;mcrypt.so and remove the ; from it.
Or, if it's not in there, just add mcrypt.so somewhere.
Also the salt option has been deprecated as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default.
Try sudo php5enmod mcrypt && sudo service apache2 restart
You've installed mcrypt when you actually wanted the php56-mcrypt php module.
You stated in your question that you can see mcrypt installed in /usr/local/Cellar and that you're using OSX. So, the easiest way to install the mcrypt PHP module on OSX using Homebrew is:
// assuming you have php56
brew install php56-mcrypt
If homebrew can't find the correct package you may need to tap the PHP repositories found on GitHub:
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
Now when you issue the command brew search mcrypt, you should see something like:
libtomcrypt mcrypt php53-mcrypt php54-mcrypt php55-mcrypt php56-mcrypt
Several other posters have mentioned the need to edit your php.ini file. This will be unnecessary as homebrew will take care of activating the module for you. It places the configuration file at /usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini
You don't have the mcrypt PHP extension installed.
For a Mac, I followed these instructions:
mcrypt on Mac 10.7 or 10.8.
They look like a lot, but it's not, it's very easy to follow in it works!
You may have installed mycrypt but not have the php_mcrypt module installed / enabled.
Just a note for people who have recently upgraded to PHP 7 - The MCRYPT library has been deprecated. If you upgraded to PHP 7 and are now seeing this error, that is why. You should switch to an alternative library, some alternatives are mentioned in this thread.
Go to the CLI folder in your php instalation, and find php.ini in there and enable mcrypt. Terminal sometimes uses another php.ini, which is usually in the CLI folder.
I installed php and mcrypt with Homebrew, but I still experienced this error after doing brew update a few times. I think my setup has just gotten a bit borked over time.
It turns out my php was being configured from /private/etc/php.ini, not /usr/local/etc/php/5.4/php.ini as Homebrew recommends. Mcrypt is not even being included from /usr/local/etc/php/5.4/ext-mcrypt.ini which doesn't make a lot of sense considering php -i produces this for me:
Configuration File (php.ini) Path => /usr/local/etc/php/5.4
Loaded Configuration File => /usr/local/etc/php/5.4/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/5.4/conf.d
Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini
My solution:
Edit /private/etc/php.ini as a superuser
Add extension="/usr/local/Cellar/php54-mcrypt/5.4.28/mcrypt.so" and save
Restart Apache with sudo apachectl restart
This is what finally worked for me:
brew reinstall --with-homebrew-curl --with-httpd php56
brew reinstall --build-from-source php56-mcrypt
I also had to do sudo chmod 777 /usr/local/etc/php/5.6/conf.d because I got errors when the second brew reinstall tried to add the ext-mcrypt.ini to that directory.

How to enable the memcached PHP extension after installing with homebrew?

I recently installed memcached with homebrew, I'm not entirely sure how to enable it on my PHP envirionment since I added extension=memcached.so in /etc/php.ini in Lion OS X.
Even I restarted apache too, nothing is still loaded.
If I call get_loaded_extensions(), I do not see memcached in the list, how can I enable it when installed from homebrew?
EDIT:
What I did in Terminal was:
$ brew install memcached
It installed just fine, now I went to /etc/php.ini and appended:
extension=memcached.so
Install Memcached:
# lists all memcached related packages
brew search memcached
# install memcached as well as memcached extension for PHP
brew install memcached
brew install php54-memcached
# start memcached daemon with 24MB on port 11211 (default)
memcached -d -m 24 -p 11211
Add to your php.ini file to add:
extension=memcached.so
Restart php or php5-fpm and your server. Verify:
php -i | grep memcached
# should show memcached version, etc.
Install:
brew install memcached
OR
sudo pecl install memcached
Add this line to /etc/php.ini:
extension = memcached.so
OR
extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so"
If you are having trouble finding where it lives do
mdfind memcached.so -name
=> /usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so
Make sure it is running as a daemon (-d):
/usr/local/bin/memcached -d
Restart apache:
sudo apachectl restart
You'll need to install libmemcached with homebrew, not just memcached. Do this:
brew install libmemcached
Then try recompiling your memcache PHP module. Should be good to go
First, install memcached library with:
sudo pecl install memcached
Then, add this line to /etc/php.ini:
extension = memcached.so
That's it.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so'
That's the information PHP is giving you, stick to it.
It's either:
The file you have specified does not exists. Check your file-system.
The file you've specified can not be read by PHP, check the rights of the file.
The file you've specified is incompatible with your PHP binary. Check if you have compiled the right sources and compilation went well.
In Mac OS X El Capitan you can use
brew install homebrew/php/php55-memcached
You can install the memcache.so module the following way:
brew install memcached-php
(Note the above is currently broken if you don't have the right Xcode version)
Then go to your php.ini file and add the following (Replace VERSION with the correct value):
extension="/usr/local/Cellar/memcached-php/VERSION/memcached.so"
Then restart apache:
sudo apachectl restart
If you can't figure out which php.ini file is being used, try calling the phpinfo() command. It will tell you exactly which php.ini file it's using.

Categories