Install Memcached + PHP Memcached Extension under Mac OS X lion

来源:互联网 发布:淘宝买家怎么样刷信誉 编辑:程序博客网 时间:2024/04/29 06:19

Install Memcached + PHP Memcached Extension under Mac OS X Snow Leopard

This step-by-step tutorial was successfully tested under Snow Leopard (OS X 10.6) with MAMP installed, but it should also work under Leopard (OS X 10.5) and without MAMP.

Copy & paste the following code line-by-line into your terminal and enter your user password whenever it is requested:

Install libevent:

cd /tmp; curl -O http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure; make
sudo make install

Install the Memcache application (called daemon because it runs in the background):

cd /tmp; curl -O http://memcached.googlecode.com/files/memcached-1.4.1.tar.gz
tar zxvf memcached-1.4.1.tar.gz
cd memcached-1.4.1
./configure; make
sudo make install

Test if the Memcache Daemon was successfully installed:

memcached -h

You should see the possible command line options for the memcache daemon. But we are not quite ready, yet. Let’s set up the PHP extension so that you can call the daemon from a PHP script:

Building the great, new PHP Memcached extension (http://de.php.net/manual/en/book.memcached.php):

cd /tmp; curl -O http://download.tangent.org/ibmemcached-1.0.10.tar.gz
tar zxvf ibmemcached-1.0.10.tar.gz
cd libmemcached-1.0.10
./configure; make
sudo make install

Installing the PHP Memcached Extension via PECL (we install 1.0.0, because 1.0.2 has an installation bug under Mac OS X):

sudo pecl install memcached-1.0.0

In the case of success you should see something similar like:

Build process completed successfully
Installing '/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so'

If you use MAMP then you should copy that newly generated memcached.so file to somewhere like /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/

And finally, add the following line to your php.ini:
extension = memcached.so

Restart your Apache and then create a new PHP script and put a <? phpinfo(); ?> inside.

Start that PHP script in your browser and search for the string “memcached”. If you find it then your memcached extension is correctly installed.

Hints:

To start your memcache daemon type this in your terminal:

memcached -d

To stop your memcache daemon type this in your terminal:

killall memcached

Filed under PHP Memcached

  1. lecloud posted this

We love Tumblr &Stationery byThijs

请使用 php-5.3.17.tar.gz libevent-2.0.20-stable.tar.gz libmemcached-1.0.10.tar.gz memcached-2.1.0.tgz
hope it will help some one who failed like me! 可以成功。


转自:http://www.lecloud.net/post/3102678831/install-memcached-php-memcached-extension-under-mac

原创粉丝点击