memcached 的Linux安装
一、memcached 的編譯安裝
準備:
Memcached下載地址:http://www.danga.com/memcached/
libevent下載地址: http://monkey.org/~provos/libevent/
1.分別把memcached和libevent下載回來,放到 /tmp 目錄下:
# cd /tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz
2.先安裝libevent:
# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure –prefix=/usr
# make
# make install
3.測試libevent是否安裝成功:
# ls -al /usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent-1.2.so.1 -> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 12 17:38 libevent-1.2.so.1.0.3
-rw-r–r– 1 root root 454156 11?? 12 17:38 libevent.a
-rwxr-xr-x 1 root root 811 11?? 12 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 12 17:38 libevent.so -> libevent-1.2.so.1.0.3
還不錯,都安裝上了。
4.安裝memcached,同時需要安裝中指定libevent的安裝位置:
# cd /tmp
# tar zxvf memcached-1.2.0.tar.gz
# cd memcached-1.2.0
# ./configure –with-libevent=/usr
# make
# make install
如果中間出現報錯,請仔細檢查錯誤信息,按照錯誤信息來配置或者增加相應的庫或者路徑。
安裝完成后會把memcached放到 /usr/local/bin/memcached ,
5.測試是否成功安裝memcached:
# ls -al /usr/local/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 12 17:39 /usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 12 17:39 /usr/local/bin/memcached-debug
?
安裝步驟:
1. 下載libevent & memcached 源碼包
???? libevent-1.3.tar.gz
???? memcached-1.2.2.tar.gz
2. 解壓縮 libevent-1.3.tar.gz ,編譯安裝
???? # tar zxvf?? libevent-1.3.tar.gz
???? # cd libevent-1.3?
???? # ./configure --prefix=/usr/local/libevent
???? # make ; make install
3. 解壓縮 memcached-1.2.2.tar.gz, 編譯安裝
???? # tar zxvf memcached-1.2.2.tar.gz?
???? # cd memcached-1.2.2?
???? # ./configure --prefix=/usr/local/memchached --with-libevent=/usr/local/libevent?
???? # make;make install
4. 作軟連接,否則運行memcached的時候將找不到libevent模塊
???? # ln -s /usr/local/libevent/lib/libevent-1.3.so.1 /usr/lib
5.啟動memcached
???? # /usr/local/memcached/bin/memcached -d -m 256 -p 11211 -u root
OK !!! 搞定! ^^
二、php的memcached模塊
# tar vxzf memcache-1.5.tgz
# cd memcache-1.5
# /usr/local/php/bin/phpize
# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
# make
# make install
安裝完后會有類似這樣的提示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/
把這個記住,然后修改php.ini,把
extension_dir = "./"
修改為
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20050922/"
并添加一行
extension=memcache.so
3、測試腳本
自己寫一個PHP程序測試一下吧
<?php
???? $memcache = new Memcache; //創建一個memcache對象
???? $memcache->connect('localhost', 11211) or die ("Could not connect"); //連接Memcached服務器
???? $memcache->set('key', 'test'); //設置一個變量到內存中,名稱是key 值是test
???? $get_value = $memcache->get('key'); //從內存中取出key的值
???? echo $get_value;
?>
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/muyannian/archive/2007/11/05/1867725.aspx
轉載于:https://www.cnblogs.com/wenanry/archive/2009/12/21/1628868.html
總結
以上是生活随笔為你收集整理的memcached 的Linux安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: flash mini播放器
- 下一篇: 关于卡巴斯基安全免疫区随笔