ubuntu12.04安装nginx1.2.2

来源:互联网 发布:淘宝店挣钱吗 编辑:程序博客网 时间:2024/06/05 19:27

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 libraryinto the system, or build the OpenSSL library statically from the sourcewith 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

http://wiki.nginx.org/