nginx從新編譯安裝upload模塊

  因爲php處理上傳會出現超時,而且顯示上傳進度官方php不支持nginx+php,因此決定讓nginx本身處理上傳,我本地環境是mac上已經安裝過nginx1.8.0,安裝方式爲brew,因此須要從新編譯nginx添加upload模塊。php

  nginx下載地址:http://nginx.org/en/download.htmlhtml

    nginx-upload-module下載地址:https://github.com/vkholodkov/nginx-upload-module/tree/2.2nginx

      解壓nginxgit

  tar xvzf nginx-1.8.0.tar.gzgithub

  nginx-upload-module解壓目錄爲:/usr/local/nginx-upload-module-2.2svn

  因爲upload模塊沒有隨着nginx的更新出新版本,因此有些地方須要修改,下載補丁文件,地址:http://paste.davromaniak.eu/index.php?show=110ui

  下載文件名爲davromaniak.txt,放入/usr/local/nginx-upload-module-2.2目錄,執行補丁spa

cp darvromaniak.txt /usr/local/nginx-upload-module-2.2  
patch ngx_http_upload_module.c davromaniak.txt 

      執行完畢後,開始編譯nginxcode

  nginx -V查看已經安裝的nginx的版本和編譯參數(這是個人nginx參數)htm

nginx version: nginx/1.8.0
built by clang 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
built with OpenSSL 1.0.2a 19 Mar 2015
TLS SNI support enabled
configure arguments: --prefix=/usr/local/Cellar/nginx/1.8.0 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.8.0/bin/nginx --with-cc-opt='-I/usr/local/Cellar/pcre/8.36/include -I/usr/local/Cellar/openssl/1.0.2a-1/include' --with-ld-opt='-L/usr/local/Cellar/pcre/8.36/lib -L/usr/local/Cellar/openssl/1.0.2a-1/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module

     cd nginx-1.8.0

     加上--add-module=/usr/local/nginx-upload-module-2.2(nginx-upload-module解壓目錄)參數從新編譯:

  

./configure --prefix=/usr/local/Cellar/nginx/1.8.0 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.8.0/bin/nginx --with-cc-opt='-I/usr/local/Cellar/pcre/8.36/include -I/usr/local/Cellar/openssl/1.0.2a-1/include' --with-ld-opt='-L/usr/local/Cellar/pcre/8.36/lib -L/usr/local/Cellar/openssl/1.0.2a-1/lib' --conf-path=/usr/local/etc/nginx/nginx.conf --pid-path=/usr/local/var/run/nginx.pid --lock-path=/usr/local/var/run/nginx.lock --http-client-body-temp-path=/usr/local/var/run/nginx/client_body_temp --http-proxy-temp-path=/usr/local/var/run/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/var/run/nginx/fastcgi_temp --http-uwsgi-temp-path=/usr/local/var/run/nginx/uwsgi_temp --http-scgi-temp-path=/usr/local/var/run/nginx/scgi_temp --http-log-path=/usr/local/var/log/nginx/access.log --error-log-path=/usr/local/var/log/nginx/error.log --with-http_gzip_static_module --add-module=/usr/local/nginx-upload-module-2.2

   編譯完成後千萬不要make && make install(否則會覆蓋安裝nginx)

   編譯成功後備份舊nginx

  cp /usr/local/Cellar/nginx/1.8.0/bin/nginx  /usr/local/Cellar/nginx/1.8.0/bin/nginx.bak

     把新的nginx程序覆蓋舊的
     cp /usr/local/nginx-1.8.0/objs/nginx /usr/local/Cellar/nginx/1.8.0/bin/nginx

到此,nginx的upload模塊安裝完畢

相關文章
相關標籤/搜索