NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
NGINX is one of a handful of servers written to address the C10K problem. Unlike traditional servers, NGINX doesn’t> NGINX powers several high-visibility sites, such as Netflix, Hulu, Pinterest, CloudFlare, Airbnb, WordPress.com, GitHub, SoundCloud, Zynga, Eventbrite, Zappos, Media Temple, Heroku, RightScale, Engine Yard, MaxCDN and many others.
Getting StartedCommunity3rd Party ModulesContributing
3、创建用户
创建系统用户nginx
useradd -r nginx
4、准备源码包:
wget http://nginx.org/download/nginx-1.8.0.tar.gz
5、安装
1)解压
tar -xf nginx-1.8.0.tar.gz
2)检查安装环境及自定义安装模块并生成Makefile
./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_dav_module --with-http_stub_status_module --with-threads --with-file-aio 注:centos 6不支持http_v2
3)编译依赖的源码,生成所有相关的目标文件
make
4)将可执行程序安装
make install
5)创建执行环境
/etc/profile
export PATH=/usr/local/nginx/sbin:$PATH
6、nginx服务的启动(注意:在这之前一定要关掉其他占用同端口80程序)
[root@localhost sbin]# nginx -h
nginx version: nginx/1.8.0
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,> -p prefix : set prefix path (default: /usr/local/nginx/)指定服务器路径前缀至文件路径
-c filename : set configuration file (default: /etc/nginx/nginx.conf)指定配置文件路径
-g directives : set global directives out of configuration file附加配置文件路径指定
nginx服务启动可直接执行二进制文件./nginx
重载服务:nginx -s> 7、Nginx的信号机制:
TERM, INT 快速关闭
QUIT
从容关闭
HUP
重新加载,用新的配置开始新的工作进程
USER1
重新打开日志文件
USER2
平滑升级可执行程序
WINCH
从容关闭工作进程
[root@localhost ~]# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 3457 0.0 0.0 44628 1756 ? Ss Oct15 0:00 nginx: master process ./nginx
nginx 11157 0.0 0.0 45072 1792 ? S 16:58 0:00 nginx: worker process
root 11221 0.0 0.0 103332 860 pts/2 S+ 17:17 0:00 grep nginx
[root@localhost ~]# kill -quit 3457
[root@localhost ~]# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 11225 2.0 0.0 103328 856 pts/2 S+ 17:17 0:00 grep nginx