首先下载源文件:

http://wiki.nginx.org/Install

加压后运行:

./configure [各种编译参数]
make
sudo make install

编译完成后,可以使用命令 /prefix/sbin/nginx -V 来查看nginx的版本和编译参数


一个较为完善的编译参数,其中还包含一些较为实用的第三方模块,例如lua-nginx-module, ngx_cache_purge
./configure --with-http_sub_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=exp/echo-nginx-module/ --add-module=exp/lua-nginx-module/ --add-module=exp/simpl-ngx_devel_kit/ --add-module=exp/set-misc-nginx-module/ --add-module=exp/ngx_cache_purge/