nginx 添加模塊
1.查看當前nginx信息(配置文件路徑,啟動用戶...)
ps aux | grep nginx
2.查看當前nginx已啟用的模塊(記錄模塊信息,安裝路徑)
./nginx -V
3.官網下載對應版本的nginx源碼包(http://nginx.org/)
http://nginx.org/en/download.html
4.上傳到服務器解壓編譯
--with-http_realip_module 是nginx自帶的模塊,如是第三方模塊下載,並關注對應的版本匹配問題
在原有模塊的基礎上添加新模塊編譯:
編譯通過后,make ;切記不要make install重新安裝
備份原nginx文件:
將編譯好的新nginx文件拿來替換:
查看替換后的nginx模塊:
重新加載nginx使模塊生效:
備注:若是第三方模塊,只要下載對應的第三方模塊(注意與nginx版本的匹配)如(ngx_pagespeed-master);解壓在對應的目錄下,編譯的時候新增--add-module=/對應目錄/ngx_pagespeed-master;如下所示:
./configure --prefix=/apprun/nginx --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_stub_status_module --with-threads --with-file-aio --with-stream --with-stream_ssl_module --with-pcre --with-http_slice_module --with-http_realip_module --add-module=/usr/local/ngx_pagespeed-master