1、下载最新nginx原码包解压
2、编译
./configure --prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_stub_status_module
然后make && make install
可能出错的几处
(1)缺少gcc-c++和libtool,也就是c++编译包
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/home/guangbo/work/pcre-8.12'
make: *** [all] Error 2
解决方法:直接在线安装apt-get install libtool
(2)缺少openssl库
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option解决方法:
sudo apt-get install libssl-dev
(3)启动报错
nginx启动出错 error while loading shared libraries: libpcre.so.1
解决方法: ln -s /usr/local/lib/libpcre.so.1 /lib
最后测试
/usr/local/nginx/sbin/nginx 然后访问
停止: /usr/local/nginx/sbin/nginx -s stop
测试: /usr/local/nginx/sbin/nginx -t
参考网址
http://www.wangzhibo.com/windows_linux/969.html
http://blog.163.com/dingding_jacky/blog/static/1669127872010101904621142/
http://peterwei.iteye.com/blog/969991