Linux下缓存服务器的应用

Linux下缓存服务器的应用

作者:tonyvicky
来自:LinuxSir.Org
摘要:由于数据库存储的数据量越来越大,查询速度也就变的越来越慢,因此就有了缓存服务器应用的必要,本文是介绍Memcached的安装以及简单的使用。

本文只介绍memcached的PHP的API,想查看其他关于Memcached的API文档案,请访问 http://www.danga.com/memcached/

目录


++++++++++++++++++++++++++++++++++++++++
正文
++++++++++++++++++++++++++++++++++++++++

一、环境需求
安装Memcached需要libevent库的支持,所以请在安装Memcached之前检查有没有安装libevent。测试环境还需要PHP的支持,本文假设PHP已经安装到/usr/local/php目录下,也就是在编译PHP的时候使用perfix参数指定目录(--prefix=/usr/local/php)

二、下载相关软件

Memcached下载地址:http://www.danga.com/memcached/
memcache PHP模块下载地址: http://pecl.php.net/package/memcache 推荐使用1.5版
libevent 下载地址: http://www.monkey.org/~provos/libevent/

本文不再讲述如何安装libevent

三、安装和配置

1、安装Memcached

 

root@tonyvicky:# tar vxzf memcached-1.1.12.tar.gz
root@tonyvicky:# cd memcached-1.1.12
root@tonyvicky:# ./configure --prefix=/usr/local/memcached
root@tonyvicky:# make
root@tonyvicky:# make install

 

安装完之后要启动服务

 

root@tonyvicky:# cd /usr/local/memcached/bin
root@tonyvicky:# ./memcached -d -m 50 -p 11211 -u root

 

参数说明 -m 指定使用多少兆的缓存空间;-p 指定要监听的端口; -u 指定以哪个用户来运行

2、安装memcache PHP模块

 

root@tonyvicky:# tar vxzf memcache-1.5.tgz
root@tonyvicky:# cd memcache-1.5
root@tonyvicky:# /usr/local/php/bin/phpize
root@tonyvicky:# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir
root@tonyvicky:# make
root@tonyvicky:# 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;
?>
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于Linux系统下的邮件服务器 "所 在 系 "信息工程系 " "专 业 "网络工程 " "班 级 "B041111 " "学 号 "B04111131 " "姓 名 "于硕 " "指导教师 "牛国新 " "负责教师 "吴兰兰 " 沈阳航空航天大学北方科技学院 2014年6月 摘 要 电子邮件服务由专门的服务器提供。主要的电子邮件服务器主要有基于Postfix/Se ndmail的邮件系统,也是在企业中使用数量最多的邮件系统。其性能可以达到非常高, 而且安全性很好,同时软件是开源免费的。 本套系统采用B/S模式开发,由服务器端和客户端两部分构成。服务器端除了提供最 基本的收发邮件功能之外,它还具有注册新用户、管理用户、群发邮件等功能。客户端 分为普通用户端和管理员端。普通用户端可实现基本的注册、收发邮件,修改个人资料 等功能,管理员端主要实现群发邮件功能,以方便主管领导发送紧急通知,除此之外, 它还可以实现浏览用户信息以及删除用户等操作。 论文从需求分析、系统设计、详细设计、系统调试与测试等方面对系统的设计过程进 行了详细的描述,并对系统待完善之处提出了建议。 关键词:Linux系统;邮件服务;域名解析;服务器 Abstract E-mail service provided by a dedicated server, but the system of large mail service providers are generally developed or to other technology development and implementation of two times. The e-mail server is a mail system based on Postfix/Sendmail. Use the largest number of mail system in enterprise. mail system based on Postfix/Sendmail is in need of a strong technical force to realize, but performance can reach very high, but very good security, and is open source and free software. This system developed based on Browser / Server module, which contains server and client. This system is constituted with server and webmail.The server provides the basic function that user can use it to send and receive mail.Besides,it also provides other functions such as :registering a new account. managing users' information. sending system message. receive and send a mail, reform person's basic message. The administrator can send many mails one time to send vital notice . In addition, the administrator also can view the users' message and delete a user's account. The papers make a detailed description on the process of system design from the aspect of needs anylasis,system design,detailed design,system debugging and testing.For the places which need to be perfect,It offered a suggection. KeyWords :Linux;Sendmail;Bind;Server 目 录 摘 要 I Abstract I 1 绪论 1 1.1课题背景 1 1.2课题目的 1 1.3课题意义 2 1.4国内外发展现状及趋势 2 1.5课题要求 3 2 可行性分析 4 2.1经济可行性分析 4 2.2技术可行性分析 4 2.3操作可行性分析 5 2.4 法律可行性 6 3

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值