Set up Memcached as a service

From: http://www.lullabot.com/articles/installing-memcached-redhat-or-centos (Lullabot)


Just having memcache installed will not do anything by itself, we need to actually start up some instances of it for our web server to connect to, and we need memcached to automatically start up when the server restarts.

For this we need to install a new script at /etc/init.d/memcached. For this I usually use a custom script that's a bit crude, since it assumes that memcached is being used exclusively for our web server. However, most of the time this is true and it works just fine.

Download the memcached script (rename to just "memcached").

So simply load this script into /etc/init.d. Then set the permissions on it to make it executable:

$ chmod 755 memcached

Then register the script to start up with the server:

$ chkconfig --add memcached

Now you can start up memcached as a service.

$ service memcached start

And you can confirm that memcached has fired up several instances by checking ps.

$ ps -e | grep memcached
22805 ?        00:00:59 memcached
22807 ?        00:00:58 memcached
22809 ?        00:01:16 memcached
22811 ?        00:00:55 memcached
22813 ?        00:00:01 memcached
22815 ?        00:01:02 memcached
22817 ?        00:00:27 memcached
22819 ?        00:00:35 memcached
22821 ?        00:00:01 memcached
22823 ?        00:00:01 memcached
22825 ?        00:00:01 memcached

And that's it! You may need to change the /etc/init.d/memcached file to match your needs depending on what you're using Memcached for. If you're using Memcached with Drupal, you can follow the instructions for changing your settings.php file by following the instructions provided with the Memcache module. Also make sure you configure your Firewall to prevent access to Memcache from external URLs.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值