nginx 添加第三方模塊

nginx 添加第三方模塊

添加第三方模塊

搭建文件服務(wù)器 fastdfs + nginx 過程中配置nginx部分遇到些許坑. 記錄為 給 ubuntu 系統(tǒng)上已有的 nginx 安裝第三方模塊 fastdfs-nginx-module

  1. nginx 信息

通過 apt 安裝的 nginx 默認(rèn)情況

/usr/sbin/nginx # 執(zhí)行文件位置
/etc/nginx/     # 配置文件目錄位置

通過 nginx -V 查看 nginx 版本及編譯參數(shù)

configure arguments 后的部分為編譯參數(shù), 簡稱"編譯參數(shù)", 之后的重新編譯步驟將用到

nginx version: nginx/1.4.6 (Ubuntu)
built by gcc 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) 
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module
  1. 下載源碼

下載nginx 源碼 apt-get source nginx

nginx_1.4.6-1ubuntu3.8.debian.tar.gz  
nginx_1.4.6-1ubuntu3.8.dsc  
nginx_1.4.6.orig.tar.gz # 源碼壓縮包
nginx-1.4.6             # 解壓的源碼文件夾

下載模塊源碼

git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cd fastdfs-nginx-module/src
pwd

獲得模塊源碼位置, 簡稱 "模塊路徑"

/usr/local/src/fastdfs-nginx-module/src/
  1. 編譯
cd nginx-1.4.6
./configure 編譯參數(shù) --add-module=模塊路徑
make

無需執(zhí)行 make install, 之心將會覆蓋系統(tǒng)原有的文件, 大可不必. 新的可執(zhí)行文件生成在 objs/nginx, 替換系統(tǒng)原有的 nginx 并重啟

sudo cp ./objs/nginx /usr/sbin
  1. 使用模塊

在必要的配置使用該模塊, 示例,進(jìn)過8888端口的請求使用到該模塊

server {
    listen 8888;
    server_name localhost;
    location ~/group[0-9]/M00/ {
        ngx_fastdfs_module;
    }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容