2 月 202013
 

下载最新版本nginx,pcre,openssl,zlib并解压缩

nginx-01-01

编译安装

 [root@localhost nginx-1.2.7]# ./configure --prefix=/usr/local/nginx \
 --with-pcre=../pcre-8.32/ --with-zlib=../zlib-1.2.7 \
 --with-openssl=../openssl-1.0.1e --with-http_ssl_module
[root@localhost nginx-1.2.7]#make
[root@localhost nginx-1.2.7]#make install

查看安装完成nginx的版本

[root@localhost sbin]# ./nginx -v
 nginx version: nginx/1.2.7

查看nginx命令参数

[root@localhost sbin]# ./nginx -h
nginx version: nginx/1.2.7
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
 -?,-h : this help
 -v : show version and exit
 -V : show version and configure options then exit
 -t : test configuration and exit
 -q : suppress non-error messages during configuration testing
 -s signal : send signal to a master process: stop, quit, reopen, reload
 -p prefix : set prefix path (default: /usr/local/nginx/)
 -c filename : set configuration file (default: conf/nginx.conf)
 -g directives : set global directives out of configuration file
[root@localhost sbin]#

启动

[root@localhost sbin]# ./nginx
 [root@localhost sbin]# netstat -lut |grep http
 tcp 0 0 *:http *:* LISTEN
 [root@localhost sbin]#

通过浏览器访问nginx服务器
nginx-01-02

错误分析1

./configure: error: the HTTP rewrite module requires the PCRE library.
 You can either disable the module by using --without-http_rewrite_module
 option, or install the PCRE library into the system, or build the PCRE library
 statically from the source with nginx by using --with-pcre=<path> option.

错误分析2

./configure: error: the HTTP gzip module requires the zlib library.
 You can either disable the module by using --without-http_gzip_module
 option, or install the zlib library into the system, or build the zlib library
 statically from the source with nginx by using --with-zlib=<path> option.

错误分析3

./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.

Nginx官方文档配置参数

--prefix=path
 --sbin-path=path
 --conf-path=path
 --pid-path=path
 --error-log-path=path
 --http-log-path=path
 --user=name
 --with-select_module
 --without-select_module
 --with-poll_module
 --without-poll_module
 --without-http_gzip_module
 --without-http_proxy_module
 --with-http_ssl_module
 --with-pcre=path
 --with-pcre-jit
 --with-zlib=path
--with-cc-opt=parameters
 --with-ld-opt=parameters

Nginx官方文档配置示例

./configure
 --sbin-path=/usr/local/nginx/nginx
 --conf-path=/usr/local/nginx/nginx.conf
 --pid-path=/usr/local/nginx/nginx.pid
 --with-http_ssl_module
 --with-pcre=../pcre-4.4
 --with-zlib=../zlib-1.1.3

相关下载:
(1)nginx 1.2.7 (2)openssl 1.0.1e (3)pcre 8.32 (4)zlib 1.2.7
内容引用:
(1)