1 note &
Install Redis & PHP Extension PHPRedis with Macports
Just recently I wanted to install Redis and the fast, because written in C, PHP extension PHPRedis on my Macbook Pro.
I learned, that I would need to recompile my PHP and decided to switch from the convenient, but not really extendable MAMP.app, to the more Linux-alike (apt get …) Macports. At the end of this article I will post some further links relating Getting-Started with Macports. I assume that you correctly installed Apache 2 and PHP 5.3.5 with Macports.
Installation of Redis Server
Head to your terminal and type the following:
sudo port selfupdate
sudo port upgrade outdated
sudo port install redis
You now installed the Redis Server! To run Redis type
sudo port install redis
… and to stop it type
sudo killall redis-server
Installation of the PHP Extension
At first, we create a new directory where we put all the source code inside, then we get the latest code via GIT and then we build it for PHP. To make it easy, just copy & paste the following lines to your terminal:
cd /usr/local
sudo mkdir src
cd /usr/local/src
sudo mkdir phpredis-build
cd phpredis-build
sudo git clone --depth 1 git://github.com/owlient/phpredis.git
cd phpredis
sudo phpize
sudo ./configure
sudo make
sudo make install
Now just create the necessary ini-file for the extension:
cd /opt/local/var/db/php5/
sudo nano redis.ini
add the line: extension = redis.so into the file and save it
Now just restart your Apache and you´re ready to go!
Links for the installation of Macports:
https://trac.macports.org/wiki/howto/MAMP
http://blogwaffe.com/2010/01/22/php-5-apache-2-mysql-5-on-os-x-via-macports/