This guide is base on Ubuntu & PHP5, so you have to install PHP5 in Ubunut first, but debian is okay.
Install Memcached
1 2
| $ sudo apt-get install memcached $ service memcached start
|
then execute ps aux | grep memcached
to check it is running.
1
| $ ps aux | grep memcached
|
Install Memcache extension for PHP
Let’s go to https://pecl.php.net/package-stats.php.
- download memcache package from https://pecl.php.net/package-stats.php to your home directory.
- extract it.
- run phpize to gererate configure, make file.
- configure
- make
- make install
1 2 3 4 5 6
| $ wget https://pecl.php.net/get/memcache-2.2.7.tgz $ tar zxf memcache-2.2.7.tgz $ phpize $ ./configure $ sudo make $ sudo make install
|
set php.ini
append extension=/path/to/memcache.so
php.ini
1
| extension=/path/to/memcache.so
|
config ThinkPHP
Go into Core/conf/conf.php
1 2 3
| 'DATA_CACHE_TYPE' => 'Memcache', 'MEMCACHE_HOST' => 'localhost', 'MEMCACHE_PORT' => '11211'
|
restart php-fpm
1 2
| $ ps aux | grep memcached $ kill pid
|