Memcached安裝並啟用PHP擴充支援

來源:互聯網
上載者:User

標籤: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-develConfiguring for:PHP Api Version:         20121113Zend Module Api No:      20121212Zend 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] ~]#

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/8A/58/wKioL1gubRyRUv24AAAjNrlVJqU556.png" title="1.png" alt="wKioL1gubRyRUv24AAAjNrlVJqU556.png" />

[[email protected] ~]# cd /usr/share/nginx/html[[email protected] html]# cat info.php<?phpphpinfo()?>[[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檔案


650) this.width=650;" src="http://s1.51cto.com/wyfs02/M01/8A/58/wKioL1gubTPgMQW4AAATmh3C_cM015.png" style="float:none;" title="1.png" alt="wKioL1gubTPgMQW4AAATmh3C_cM015.png" />

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M01/8A/58/wKioL1gubTODUp7cAAAZT93CvoI266.png" style="float:none;" title="2.png" alt="wKioL1gubTODUp7cAAAZT93CvoI266.png" />

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

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/8A/58/wKioL1gubUzhw-MRAAAzjDbMYsA456.png" style="float:none;" title="1.png" alt="wKioL1gubUzhw-MRAAAzjDbMYsA456.png" />

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M00/8A/5C/wKiom1gubU2yErrtAAAk9dHBXc8665.png" style="float:none;" title="2.png" alt="wKiom1gubU2yErrtAAAk9dHBXc8665.png" />


Nginx配置:

[[email protected] ~]# cat /etc/nginx/conf.d/default.confserver {    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-redirectfastcgi_param  REDIRECT_STATUS    200;[[email protected] ~]#

成功。


本文出自 “鵬城-醬油瓶” 部落格,謝絕轉載!

Memcached安裝並啟用PHP擴充支援

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.