nginx1.8编译安装

概述

nginx [engine x] 是一个HTTP反向代理服务器,一个邮件代理服务器,一个通用的TCP/UDP代理服务器
官方文档

编译安装

1
2
3
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-pcre=/usr/local/pcre-8.10 --with-openssl=/usr/local/openssl-1.0.1p --with-zlib=/usr/local/zlib-1.2.7

make && make install

–with-http_ssl_module #支持ssl
–with-http_stub_status_module #支持status
–with-http_gzip_static_module #支持gzip
–with-http_realip_module #允许从请求标头更改客户端的IP地址值
–with-pcre=/usr/local/pcre-8.10 #设置pcre源目录
–with-openssl=/usr/local/openssl-1.0.1p #设置openssl源目录
–with-zlib=/usr/local/zlib-1.2.7 #设置zlib源目录

基本操作

nginx 帮助说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/usr/local/nginx/sbin/nginx -h

nginx version: nginx/1.8.1
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

启动

1
/usr/local/nginx/sbin/nginx

快速停止

1
/usr/local/nginx/sbin/nginx -s stop

优雅停止

1
/usr/local/nginx/sbin/nginx -s quit

重载

1
/usr/local/nginx/sbin/nginx -s reload

重新打开日志文件

1
/usr/local/nginx/sbin/nginx -s reopen
坚持原创技术分享,您的支持将鼓励我继续创作!.