1、從官網在線下載最新的安裝包
wget http://memcached.org/downloads/memcached-1.4.34.tar.gz 該命令為在線下載
注意:最新的地址會變動,所以最好去官網上看看
2、賦權限 chmod 777 文件名
3、解壓memcached安裝包
解壓命令:tar -zvxf 文件名
4、cd memcached文件夾
5、./configure && make && make install
出現報錯:
解決方法:
第一,我安裝了libevent
安裝步驟:
tar -xzvf libevent-1.3b.tar.gz
cd libevent-1.3b
./configure --prefix=/安裝目錄
make && make install
測試是否安裝成功
ls -al /usr/lib | grep libevent
第二,
cd memcached
./configure && make && make install
依舊存在該問題
specify its path using --with-libevent=/dir/
該錯誤是告訴我們要配置libevent地址
6、於是我配置了
./configure --prefix=memcached文件目錄 -- with-libevent=libevent文件目錄
這個命令的意思:
./configure --變量名=某個值 就是設置這個變量的值
命令行要切換到這個目錄下才能設置里面的 configure 文件
6、 make && make install
7、 測試安裝是否成功
命令: ls -al /app/memcached/lmemcached文件夾 | grep memcached
8、配置環境變量
#cd ~
[root@localhost ~]# vi /etc/profile
export PATH="/app/memcached/memcached-1.4.34/bin:$PATH"
使其生效
[root@localhost ~]# source /etc/profile
測試是否生效
[root@localhost ~]# ps -ef | grep memcached
root 18683 18214 0 01:21 pts/1 00:00:00 grep memcached
[root@localhost ~]# telnet 192.168.10.156 12000
Trying 192.168.10.156...
telnet: connect to address 192.168.10.156: Connection refused
[root@localhost ~]# memcached -d -p 12000
can't run as root without the -u switch
[root@localhost ~]# su llxx
[llxx@localhost root]$ memcached -d -p 12000
[llxx@localhost root]$ ps -ef | grep memcached
500 18708 1 0 01:23 ? 00:00:00 memcached -d -p 12000
500 18716 18692 0 01:23 pts/1 00:00:00 grep memcached
OK可以成功使用了。