最近要來更新一下 nginx 了,目的是想使用第三方 modules,並希望依據 Ubuntu 內建 nginx 的佈設規劃。
作法就是用內建 nginx -V 查看目前編譯所下的指令,接著下載新版 nginx 後,再下載第三方 modules 後,就可以編一編,補一補缺的 library 後,即可收工。
$ which nginx
/usr/sbin/nginx
$ nginx -V
nginx version: nginx/1.1.19
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam --add-module=/build/buildd/nginx-1.1.19/debian/modules/chunkin-nginx-module --add-module=/build/buildd/nginx-1.1.19/debian/modules/headers-more-nginx-module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-development-kit --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-http-push --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-lua --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upload-module --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upload-progress --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair --add-module=/build/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module
$ cd /tmp
$ curl http://nginx.org/download/nginx-1.3.14.tar.gz | tar -xzvf -
$ cd nginx-1.3.14 && mkdir modules
$ cd modules
$ git clone git://github.com/chaoslawful/lua-nginx-module.git
$ cd /tmp/nginx-1.3.14
$ ./configure --sbin-path=/usr/sbin/nginx --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=modules/lua-nginx-module
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/etc/nginx"
nginx binary file: "/usr/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
$ make
$ sudo nginx -s stop
$ sudo apt-get remove nginx
$ sudo make install
$ nginx -v
nginx version: nginx/1.3.14
$ sudo service nginx start
不過,其實上述除了將 nginx 更新為 1.3.14 外,其實還很多 modules 未安裝,可以先用 apt-get source 查看 Ubuntu 內建的 modules
$ sudo apt-get source nginx
$ ls nginx-1.1.19/debian/modules/
chunkin-nginx-module nginx-auth-pam nginx-development-kit nginx-lua nginx-upstream-fair
headers-more-nginx-module nginx-cache-purge nginx-echo nginx-upload-module README.Modules-versions
naxsi nginx-dav-ext-module nginx-http-push nginx-upload-progress
因此,若只增加第三方 modules 的話,且該 modules 可在 1.1.19 運行的話,也能考慮用 apt-get source 後,把第三方 modules 擺好,再 configure 為原先 nginx 的項目外,再增加一個 ---add-module=/path/3rdModules/name 即可。此外,編譯第三方 modules 時,碰到一些 warning 訊息,可以考慮 configure 時多增加 --with-cc-opt=-Wno-error 來避開(不然就手動去改 source code)。
其他 Ubuntu 額外安裝項目:
$ sudo apt-get install libsp-gxmlcpp-dev libgd2-xpm-dev libgeoip-dev libperl-dev libluajit-5.1-dev liblua5.2-dev
沒有留言:
張貼留言