I. Installation of Redis
1, installation Homebrew
Enter Ruby-e "$ (Curl-fssl https://raw.github.com/Homebrew/install/master/install)" in terminal to install Homebrew
" $ (curl-fssl https://raw.github.com/Homebrew/install/master/install) "
2. Installing Redis via Homebrew
In Terminal input Brew install Redis installation Redis
$ Brew Install Redis
3. Start and stop Redis
Start Redis by running Redis-server directly
$ redis-server
The Redis server uses port 6379 by default, and the port number can be customized with the--port parameter:
$ redis-server--port 6380
Stop Redis
$ redis-cli Shutdown
This is the end of the Redis installation section.
Ii. thinkphp Use of Redis
The thinkphp can support Redis as a cache, with a Redis cache driver (CacheRedis.class.php).
1. Mac OS x installation Phpredis extension
$ Brew Install Homebrew/php/php56-redis
Because I mamp pro with the php5.6.10 version, so is Php56-redis, installed Php56-redis can be viewed in/usr/local/cellar, the directory of redis.so is what we want to introduce.
2. MAMP MRP Load Redis Extension
Modify the php.ini file to add the following Redis extension code
Extension=/usr/local/cellar/php56-redis/2.2.7_1/redis.so
php.ini files can be found through the Mamp Pro Top navigation bar File->edit template->php->php5.6.10 php.ini
3. Restart the service to make the configuration effective
4. config.php files in the project increase Redis-related configuration items
" data_cache_type ' = ' redis ' " Data_cache_time = 3600,
redis_host = "127 .0.0.1 " redis_port ' = 6379
5. Write a demo file test
Public function Test () { $Cache = cache::getinstance (' Redis '); $Cache->set (' name ', ' thinkphp '); Echo $Cache->get (' name ');}
Page display thinkphp means normal use
Third, PostScript
First install Phpredis is installed by manually download Zip package, resulting in Mamp Pro later Apache boot can not, try a variety of methods are not, at this time my heart is a crash T, fortunately finally in the help of the old man to re-download the latest version of the Mamp on the solution, The reason is that the version is too old and the system is incompatible, so after giving up this installation, replaced by the use of brew installed successfully, encountered many holes along the way, such as phpize error, solution reference: http://my.oschina.net/Twitter/blog/287543
Redis and Thinkphp3.1 are installed under Mac OS X