源码安装Nginx
- 安装必要软件
- 安装pcre
为了支持rewrite功能
$ sudo apt-get install libpcre3 libpcre3-dev
- 安装openssl
需要ssl的支持,如果不需要ssl支持,请跳过这一步
$ sudo apt-get install openssl
- 安装Nginx
$ ./configure --prefix=/usr/local/nginx-1.7.1 \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre
参数解释
- --with-http_stub_status_module:支持nginx状态查询
- --with-http_ssl_module:支持https
- --with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持
- --with-pcre:为了支持rewrite重写功能,必须制定pcre
$ make
$ make install
- 启动、关闭、重启nginx
- 启动
/usr/local/nginx-1.7.1/sbin/nginx
- 关闭
/usr/local/nginx-1.7.1/sbin/nginx -s stop
- 重启
/usr/local/nginx-1.7.1/sbin/nginx -s reload
- 一些安装参数解释
- --prefix= 指向安装目录
- --sbin-path= 指向(执行)程序文件(nginx)
- --conf-path= 指向配置文件(nginx.conf)
- --error-log-path= 指向错误日志目录
- --pid-path= 指向pid文件(nginx.pid)
- --lock-path= 指向lock文件(nginx.lock)
- --user= 指定程序运行时的非特权用户
- --group= 指定程序运行时的非特权用户组
- --builddir= 指向编译目录
- --with-rtsig_module 启用rtsig模块支持(实时信号)
- --with-select_module 启用select模块支持(一种轮询模式,不推荐在高载环境下使用)禁用:--without-select_module
- --with-poll_module 启用poll模块支持(功能与select相同,与select特性相同,为一种轮询模式,不推荐在高载环境下使用)
- --with-file-aio 启用file aio支持(一种APL文件传输格式)
- --with-ipv6 启用ipv6支持
- --with-http_ssl_module 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
- --with-http_realip_module 启用ngx_http_realip_module支持(这个模块允许从请求标头更改客户端的IP地址值,默认为关)
- --with-http_addition_module 启用ngx_http_addition_module支持(作为一个输出过滤器,支持不完全缓冲,分部分响应请求)
- --with-http_xslt_module 启用ngx_http_xslt_module支持(过滤转换XML请求)
- --with-http_image_filter_module 启用ngx_http_image_filter_module支持(传输JPEG/GIF/PNG 图片的一个过滤器)
- --with-http_geoip_module 启用ngx_http_geoip_module支持(该模块创建基于与MaxMind GeoIP二进制文件相配的客户端IP地址的ngx_http_geoip_module变量)
- --with-http_sub_module 启用ngx_http_sub_module支持(允许用一些其他文本替换nginx响应中的一些文本)
- --with-http_dav_module 启用ngx_http_dav_module支持(增加PUT,DELETE,MKCOL:创建集合,COPY和MOVE方法)默认情况下为关闭,需编译开启
- --with-http_flv_module 启用ngx_http_flv_module支持(提供寻求内存使用基于时间的偏移量文件)
- --with-http_gzip_static_module 启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
- --with-http_random_index_module 启用ngx_http_random_index_module支持(从目录中随机挑选一个目录索引)
- --with-http_secure_link_module 启用ngx_http_secure_link_module支持(计算和检查要求所需的安全链接网址)
- --with-http_degradation_module 启用ngx_http_degradation_module支持(允许在内存不足的情况下返回204或444码)
- --with-http_stub_status_module 启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
- --without-http_charset_module 禁用ngx_http_charset_module支持(重新编码web页面,但只能是一个方向--服务器端到客户端,并且只有一个字节的编码可以被重新编码)
- 其他参数请参考连接