Memcached安装并启用PHP扩展支持

环境:Centos 6.6

PHP version:5.5.38

memcached version:1.4.33

官网:https://memcached.org/

Memcached Githup:https://github.com/memcached/memcached/wiki

安装libevent:

[[email protected] ~]# ntpdate time.windows.com
[[email protected] ~]# wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
[[email protected] ~]# tar -zxf libevent-2.0.21-stable.tar.gz
[[email protected] ~]# cd libevent-2.0.21-stable
[[email protected] libevent-2.0.21-stable]# ./configure --prefix=/usr/local/libevent
[[email protected] libevent-2.0.21-stable]# make && make install
[[email protected] ~]# ls /usr/local/libevent/
bin  include  lib
[[email protected] ~]#

安装Memcached:

[[email protected] ~]# wget https://memcached.org/files/memcached-1.4.33.tar.gz
[[email protected] ~]# tar -zxf memcached-1.4.33.tar.gz
[[email protected] ~]# cd memcached-1.4.33
[[email protected] memcached-1.4.33]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/
[[email protected] memcached-1.4.33]# make && make install
[[email protected] ~]# ls /usr/local/memcached/
bin  include  share
[[email protected] ~]#

安装php扩展模块memcache:

[[email protected] ~]# yum -y install php55w php55w-cli php55w-common php55w-devel php55w-gd php55w-odbc php55w-mysql php55w-fpm nginx
[[email protected] ~]# wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
[[email protected] ~]# tar -zxf zlib-1.2.8.tar.gz
[[email protected] ~]# cd zlib-1.2.8
[[email protected] zlib-1.2.8]# ./configure --prefix=/usr/local/zlib
[[email protected] zlib-1.2.8]# make && make install
[[email protected] ~]# wget http://pecl.php.net/get/memcache-2.2.7.tgz
[[email protected] ~]# tar -xf memcache-2.2.7.tgz
[[email protected] ~]# cd memcache-2.2.7
[[email protected] memcache-2.2.7]# phpize         //如果没有安装phpize,安装php55w-devel
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212
[[email protected] memcache-2.2.7]#
[[email protected] memcache-2.2.7]# ./configure --enable-memcache --with-php-config=/usr/bin/php-config --with-zlib-dir=/usr/local/zlib/
[[email protected] memcache-2.2.7]# make && make install
····
Installing shared extensions:     /usr/lib64/php/modules/
[[email protected] memcache-2.2.7]#
[[email protected] memcache-2.2.7]# make test

在php.ini文件,在zend之前加入如下代码:

[[email protected] ~]# head -352 /etc/php.ini | tail -3
[memcache]
extension_dir = "/usr/lib64/php/modules/"
extension = memcache.so
[[email protected] ~]#

[[email protected] ~]# cd /usr/share/nginx/html
[[email protected] html]# cat info.php
<?php
phpinfo()
?>
[[email protected] html]#
[[email protected] ~]# /etc/init.d/php-fpm start
[[email protected] ~]# /etc/init.d/nginx start
[[email protected] ~]# chkconfig --add php-fpm
[[email protected] ~]# chkconfig --add nginx
[[email protected] ~]# chkconfig php-fpm on
[[email protected] ~]# chkconfig nginx on

//启动Memcached

[[email protected] ~]# /usr/local/memcached/bin/memcached -d -u root -m 512 -p 11211 127.0.0.1 -c 10240 -P /usr/local/memcached/memcached.pid

//指定启动线程数,默认启动4个线程

启动参数说明:

  -d   选项是启动一个守护进程,
  -m  是分配给Memcache使用的内存数量,单位是MB,默认64MB
  -M  return error on memory exhausted (rather than removing items)
  -u  是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户。
  -l   是监听的服务器IP地址,默认为所有网卡。
  -p  是设置Memcache的TCP监听的端口,最好是1024以上的端口
  -c  选项是最大运行的并发连接数,默认是1024
  -P  是设置保存Memcache的pid文件

[[email protected] ~]# php -m | grep memcache
memcache
[[email protected] ~]#


Nginx配置:

[[email protected] ~]# cat /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  192.168.70.188;
    charset utf8;
    access_log  /var/log/nginx/log/host.access.log  main;
    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }
    location ~ ^(.+.php)(.*)$ {
root /usr/share/nginx/html;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        include fastcgi.conf;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  PATH_INFO          $fastcgi_path_info;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
[[email protected] ~]#
[[email protected] ~]# cat /etc/nginx/fastcgi.conf 
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;
[[email protected] ~]#

成功。

时间: 2024-08-04 22:36:40

Memcached安装并启用PHP扩展支持的相关文章

ubuntu14.04上Virtualbox安装win7(使用Ghost镜像安装,启用USB设备支持,设置共享目录)

由于某些软件只有windows版本,于是只好安装个虚拟机win7 /**************************安装*************************************/ Virtualbox 直接在软件中心就有,安装一下就行 然后随便搜索了个win7的镜像,找到很多都是Ghost镜像,那就下个Ghost吧 然后,新建了个win7虚拟机,把下载的iso加载进去,开机后,发现出问题了,无法直接ghost安装,只能进入PE,失败了好几次 后来尝试出解决方法如下 1,新建

Memcached安装与启用

Memcache概述:   Memcache是一个高性能的分布式的内存对象缓存系统,通过在内存里维护一个统一的巨大的hash表,它能够用来存储各种格式的数据,包括图像.视频.文件以及数据库检索的结果等.简单的说就是将数据调用到内存中,然后从内存中读取,从而大大提高读取速度. Memcached是以守护程序方式运行于一个或多个服务器中,随时会接收客户端的连接和操作. Memcache安装: 1:下载libevent与memcache软件包. libevent下载地址:http://monkey.o

centos php 安装memcached 扩展 支持sasl

1.安装sasl yum install cyrus-sasl-lib.x86_64 yum install cyrus-sasl-devel.x86_64 2.下载libmemcached wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz 3,编译安装 tar zxvf libmemcached-1.0.16.tar.gz cd libmemcached-1.0.16

Linux Memcached安装以及PHP扩展安装

一:安装libevent 由于memcached安装时,需要使用libevent类库,所以先安装libevent 1.下载 #wget   http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz 2.解压缩 #tar xzfv  libevent-2.0.12-stable.tar.gz 3.进入目录 #cd libevent-2.0.12-stable 4. 编译,安装# ./configure# make# make insta

WDCP,LNMP安装PHP缓存加速扩展eAccelerator,xcache和memcached

VPS主机性能配置如果太差,则在运行Wordpress博客和Discuz! 论坛等高消耗程序时能够明显感觉出VPS有些吃力.另外,即使VPS主机的CPU.内存.硬盘I/O等性能足够好,但是在面对大流量时则有可能导致PHP执行效率降低,网页打开速度变慢等不正常的情况. 为了能够在低配置的VPS主机上Web也能跑出流畅的感觉和在面对流量高峰时服务器也能从容应对大量的应该访问请求,我们一般会给PHP安装上几点缓存加速扩展:eAccelerator,xcache和memcached,优化动态内容缓存,提

window 如何找memcached 扩展以及如何把memcached 安装成服务

一.在window php 操作memcached 需要找到合适的扩展,扩展在官方下载,地址是: PHP 5.2/5.3的Windows扩展索引站点: 在这里你可以找到诸如php_oci8.dll, php_memcache.dll, php_mongo.dll, php_apc.dll等常用的Windows扩展dll文件,也能找到一些相对冷门但是也很实用的php扩展,如php_oauth.dll, php_solr.dll等扩展 http://downloads.php.net/pierre/

Linux 安装Memcache扩展支持

查看相关软件包 yum search memcached 安装memcache yum -y install memcachedMemcache关联php yum -y install php-pecl-memcache验证安装结果 memcached -h php -m | grep memcache 添加PHP的Memcache扩展 yum install php-pecl-memcache yum install zlib-devel pecl install memcache 在PHP配

php扩展memcache和memcached安装

首先简单介绍下memcache和memcached的区别 两个不同版本的php的memcached的客户端new memcache是pecl扩展库版本new memcached是libmemcached版本 memcache最早是在2004年2月开发的,最后更新是在2013年4月,而memcached最早是在2009年1月开发的,最后更新是在2014年1月更新的.所以memcache的历史比memcached早. 在安装memcache扩展的时候并不要求安装其他东东,但是在安装memcached

Linux下PHP5.2安装curl扩展支持https

问题: 线上运行的LNMP服务器,因历史原因安装的curl模块只支持http,不支持https.类似请求或POST微信接口(小程序),都无法正常使用. 一.解决方法: 编译安装curl,重新编译php,使php的curl模块支持https. cd /data0/software1.下载安装curlwget http://curl.haxx.se/download/curl-7.44.0.tar.gztar zxvf curl-7.44.0.tar.gzcd curl-7.44.0./config