linux php安裝memcached擴充

來源:互聯網
上載者:User

標籤:src   提示   nobody   linu   memcache   包括   comm   make   disable   

memcached的安裝包括:1、服務端的安裝;2、用戶端的安裝

一、伺服器端安裝

方法一:

memcached 依賴於libevent 庫,因此我們需要先安裝libevent.

假設將源碼放在/usr/local/src

1 cd /usr/local/src2 wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz3 tar zxvf libevent-2.0.22-stable.tar.gz4 cd libevent-2.0.22-stable5 ./configure --prefix=/usr/local/libevent6 make && make install

安裝memcached伺服器版

1 cd /usr/local/src2 wget http://www.memcached.org/files/memcached-1.4.33.tar.gz3 tar zxvf memcached-1.4.33.tar.gz4 cd memcached-1.4.335 ./configure --prefix=/usr/local/memcached 6 --with-libevent=/usr/loca/libevent7 make && make install

啟動memcached

1 /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -vv

顯示如上說明memcached伺服器端安裝啟動成功並把資訊輸出到控制台

想後台運行加-d選項

1 /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d
1 ps aux | grep memcached

查詢進程是否有memcached

 

啟動成功

方法二:

1 yum -y install memcached

就這一步我們就安裝完了

啟動memcached

1 /usr/bin/memcached -l 127.0.0.1 -p 11211 -m 150 -u root

顯示如方法二啟動結果

二、用戶端安裝

用戶端需安裝libmemcached庫

1 cd /usr/local/src2 wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz3 tar zxvf libmemcached-1.0.18.tar.gz4 cd libmemcached-1.0.185 ./configure --prefix=/usr/local/libmemcached6 make && make install

安裝php-fpm的memcached擴充

1 cd /usr/local/src2 wget http://pecl.php.net/get/memcached-2.2.0.tgz3 tar zxvf memcached-2.2.0.tgz4 cd memcached-2.2.0

到了這一步,我們要使用安裝php時產生的 phpize 來產生 configure 設定檔

1 /usr/local/php/bin/phpize 2 --with-php-config=/usr/local/php/bin/php-config3 ./configure --with-php-config=/usr/local/php/bin/php-config 4 --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl5 make && make install

--with-php-config 指定 php-config,該檔案與 phpize 所在目錄相同, 

--with-libmemcached-dir 指定 libmemcached 安裝目錄,就剛才我們 --prefix 那個目錄 ,

--disable-memcached-sasl 說明我們系統不支援sasl.h

如果安裝成功,會提示:Installing shared extension:/usr/local/php/lib/extensions/no-debug-non-zts-20160524/ 等類資訊

接下來,我們編輯php設定檔php.ini,把 php-memcached 擴充加到設定檔。

在 php.ini 中添加以下內容:

1 extension=memcached.so

最後重啟nginx和php-fpm

linux php安裝memcached擴充

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.