CentOS 6.7 编译安装Nginx 1.8.0

1、配置编译环境

 yum update && yum upgrade
yum groupinstall "Development Tools"

或者

yum install gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libpcre3 libpcre3-dev zlib1g-dev unzip git

2、下载Nginx 1.8

wget http://nginx.org/download/nginx-1.8.0.tar.gz

3、解压并进入目录

 tar -zxvf nginx-1.8..tar.gz
cd nginx-1.8.

4、配置编译参数

简洁版

./configure

定制版(可根据生产要求定制需要的模块)

 ./configure \
--prefix=/usr/local/nginx \
--with-pcre \
--with-http_ssl_module \
--with-http_spdy_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_auth_request_module \
--with-http_stub_status_module \
--with-http_image_filter_module \
--with-http_gzip_static_module

编译成功会显示:

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"

5、安装

make && make install

6、启动Nginx

 cd /usr/local/nginx/sbin/
./nginx

启动成功后可以使用netstat查看

netstat -tunlp | grep nginx

7、停止Nginx

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

或者

pkill nginx

8、重启Nginx

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

9、测试配置文件

/usr/local/nginx/sbin/nginx -t

10、Nginx支持信号控制

TERM, IN    快速关闭
QUIT 从容关闭
HUP 重载配置
USR1 重新打开日志文件
USR2 平滑升级可执行程序
WINCH 从容关闭工作进程

例如,快速关闭Nginx

kill -TERM (nginx PID)
上一篇:手动编译部署LNMP环境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)


下一篇:ios程序播放音频文件