nginx新增memcache模組

2021-09-28 17:09:54 字數 1317 閱讀 2180

1.什麼是openresty?

openresty(又稱:ngx_openresty) 是乙個基於 nginx 的可伸縮的 web平台,由中國人章亦春發起,提供了很多高質量的第三方模組。

openresty 是乙個強大的 web 應用伺服器,web 開發人員可以使用 lua 指令碼語言調動 nginx 支援的各種 c 以及lua 模組,更主要的是在效能方面,openresty可以 快速構造出足以勝任 10k 以上併發連線響應的超高效能 web 應用系統。

openresty 的目標是讓你的 web 服務直接跑在 nginx 服務內部,充分利用 nginx 的非阻塞 i/o 模型,不僅僅對 http 客戶端請求,甚至於對遠端後端諸如 mysql,postgresql,~memcaches 以及 ~redis 等都進行一致的高效能響應。

所以對於一些高效能的服務來說,可以直接使用 openresty 訪問 mysql或redis等,而不需要通過第三方語言(php、python、ruby)等來訪問資料庫再返回,這大大提高了應用的效能。

參考openresty中文官網

原nginx不支援memcache

1)給nginx新增memc和sr cache模組,讓nginx直接訪問memcache來提高速度

先關閉原來的nginx,因為下面安裝的openresty-1.13.6.1.tar.gz也是nginx

nginx -s stop

原始碼編譯安裝openresty-1.13.6.1.tar.gz(不需要加引數,使用預設)

./configure --prefix=/usr/local/openresty

gmake && gmake install

拷貝之前example.php和index.php到預設發布目錄準備測試

/usr/local/openresty/nginx/html

[root@server5 html]# cp /usr/local/lnmp/nginx/html/index.php .

[root@server5 html]# cp /usr/local/lnmp/nginx/html/example.php .

修改nginx配置檔案:vim /usr/local/openresty/nginx/conf/nginx.conf

新增:upstream memcache

location /memc 

location ~ \.php$

再次進行壓測,速度會比之前只加了php的快取更快

###重點說明一下對index.php頁面的訪問

訪問速度有了明顯的差別 因為php是沒有快取的

linux下PHP中新增memcache擴充套件支援

yum install libevent devel wget tar zxvf memcached 1.4.5.tar.gz configure prefix usr local memcached build i686 pc linux gnu 這一步會看到缺少gcc yum install g...

PHP中新增memcache擴充套件支援

yum install libevent devel wget tar zxvf memcached 1.4.5.tar.gz configure prefix usr local memcached build i686 pc linux gnu 這一步會看到缺少gcc yum install g...

在 linux下新增memcache擴充套件

今天在linux下給phpfpm新增擴充套件memcache擴充套件是遇到了一下問題 直接在php.ini裡面新增 mecache擴充套件 extension usr local php lib php memcache.dll 根據這個裡提示終於完成,然後自己打算再整理乙份 首先在http pec...