一、配置编译环境nginx
1 yum update && yum upgrade 2 yum groupinstall "Development Tools"
或者c++
yum install gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libpcre3 libpcre3-dev zlib1g-dev unzip git
二、下载Nginx 1.8git
wget http://nginx.org/download/nginx-1.8.0.tar.gz
三、解压并进入目录测试
1 tar -zxvf nginx-1.8.0.tar.gz 2 cd nginx-1.8.0
四、配置编译参数spa
简洁版日志
./configure
定制版(可根据生产要求定制须要的模块)code
1 ./configure \ 2 --prefix=/usr/local/nginx \ 3 --with-pcre \ 4 --with-http_ssl_module \ 5 --with-http_spdy_module \ 6 --with-http_realip_module \ 7 --with-http_addition_module \ 8 --with-http_sub_module \ 9 --with-http_auth_request_module \ 10 --with-http_stub_status_module \ 11 --with-http_image_filter_module \ 12 --with-http_gzip_static_module
编译成功会显示:blog
Configuration summary + using system PCRE library + using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
五、安装进程
make && make install
六、启动Nginxip
1 cd /usr/local/nginx/sbin/ 2 ./nginx
启动成功后能够使用netstat查看
netstat -tunlp | grep nginx
七、中止Nginx
/usr/local/nginx/sbin/nginx -s stop
或者
pkill nginx
八、重启Nginx
/usr/local/nginx/sbin/nginx -s reload
九、测试配置文件
/usr/local/nginx/sbin/nginx -t
十、Nginx支持信号控制
TERM, IN 快速关闭 QUIT 从容关闭 HUP 重载配置 USR1 从新打开日志文件 USR2 平滑升级可执行程序 WINCH 从容关闭工做进程
例如,快速关闭Nginx
kill -TERM (nginx PID)