手机版
你好,游客 登录 注册
背景:
阅读新闻

Linux下Memcached+Nginx+PHP安装手册

[日期:2013-05-26] 来源:Linux社区  作者:xinyuyuanm [字体: ]

Linux下Memcached+Nginx+PHP安装手册

Memcached安装

1. 源码安装libevent(下载地址:http://monkey.org/~provos/libevent/

2. 源码安装memcached(下载地址:http://memcached.org/

安装libevent:

tar xzf libevent-2.0.21-stable.tar.gz &&

cd libevent-2.0.21-stable&&

./configure -prefix=/usr/local/libevent&&

make && make install

检查是否安装胜利

ls -al/usr/local/libevent/lib | grep libevent

lrwxrwxrwx. 1 root root 21 5月 15 14:35 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9

-rwxr-xr-x. 1 root root 968738 5月 15 14:35libevent-2.0.so.5.1.9

-rw-r--r--. 1 root root 1572018 5月 15 14:35 libevent.a

lrwxrwxrwx. 1 root root 26 5月 15 14:35 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.9

-rwxr-xr-x. 1 root root 585281 5月 15 14:35libevent_core-2.0.so.5.1.9

-rw-r--r--. 1 root root 978666 5月 15 14:35libevent_core.a

-rwxr-xr-x. 1 root root 985 5月 15 14:35 libevent_core.la

lrwxrwxrwx. 1 root root 26 5月 15 14:35 libevent_core.so -> libevent_core-2.0.so.5.1.9

lrwxrwxrwx. 1 root root 27 5月 15 14:35 libevent_extra-2.0.so.5 ->libevent_extra-2.0.so.5.1.9

-rwxr-xr-x. 1 root root 404860 5月 15 14:35libevent_extra-2.0.so.5.1.9

-rw-r--r--. 1 root root 593424 5月 15 14:35libevent_extra.a

-rwxr-xr-x. 1 root root 992 5月 15 14:35 libevent_extra.la

lrwxrwxrwx. 1 root root 27 5月 15 14:35 libevent_extra.so -> libevent_extra-2.0.so.5.1.9

-rwxr-xr-x. 1 root root 950 5月 15 14:35 libevent.la

lrwxrwxrwx. 1 root root 30 5月 15 14:35 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.9

-rwxr-xr-x. 1 root root 18438 5月 15 14:35libevent_pthreads-2.0.so.5.1.9

-rw-r--r--. 1 root root 18678 5月 15 14:35libevent_pthreads.a

-rwxr-xr-x. 1 root root 1013 5月 15 14:35libevent_pthreads.la

lrwxrwxrwx. 1 root root 30 5月 15 14:35 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.9

lrwxrwxrwx. 1 root root 21 5月 15 14:35 libevent.so -> libevent-2.0.so.5.1.9

 

安装memcached,同时须要安装中指定libevent的安装位置:

tar xzf memcached-1.4.15.tar.gz&&

cd memcached-1.4.15&&

./configure --with-libevent=/usr/local/libevent&&

make &&make install

测试是否胜利安装memcached:

ls -al/usr/local/bin/mem*
-rwxr-xr-x. 1 root root 310847 5月 11 11:11 /usr/local/bin/memcached

编写 memcached 启动脚本

vi /etc/init.d/memcached

#! /bin/sh

#

# chkconfig: - 55 45

# description: The memcached daemon is a network memorycache service.

# processname: memcached

# config: /etc/sysconfig/memcached

 

# Source function library.

. /etc/rc.d/init.d/functions

 

PORT=11211

USER=root

MAXCONN=1024

CACHESIZE=64

OPTIONS=""

 

if [ -f /etc/sysconfig/memcached];then

. /etc/sysconfig/memcached

fi

 

# Check that networking is up.

if [ "$NETWORKING" ="no" ]

then

exit 0

fi

 

RETVAL=0

 

start () {

echo "Starting memcached ..."

# insure that /var/run/memcached has proper permissions

chown $USER /usr/local/bin/memcached

/usr/local/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN-P /var/run/memcached.pid $OPTIONS

RETVAL=$?

echo

[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached

}

stop () {

echo "Stopping memcached ..."

killproc memcached

RETVAL=$?

echo

if [ $RETVAL -eq 0 ] ; then

rm -f /var/lock/subsys/memcached

rm -f /var/run/memcached.pid

fi

}

 

restart () {

stop

start

}

 

 

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

status)

status memcached

;;

restart|reload)

restart

;;

condrestart)

[ -f /var/lock/subsys/memcached ] && restart || :

;;

*)

echo $"Usage: $0{start|stop|status|restart|reload|condrestart}"

exit 1

esac

 

exit $RETVAL

 

保存退出

 

加入自启动

cd /etc/init.d &&

chmod +x memcached &&

chkconfig --addmemcached &&

chkconfig memcachedon

 

赋给可执行权限

chmod -R 755 /etc/init.d/memcached

启动服务

service memcachedstart

查看端口是否启动胜利

netstat -anp | grep 11211

linux
相关资讯       Memcached  Linux安装Memcached  Linux安装Nginx 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款