nginx编译安装

1.安装编译工具:
yum -y install gcc gcc-c++ autoconf automake
2.安装组件:
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

说明:

pcre: 用来作地址重写的功能。

zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。

openssl:提供ssl加密协议。

3.查看是否有遗留的nginx文件,最好改为old,省的冲突

find -name nginx

如果系统已经安装了nginx,那么就先卸载

 
4.编译参数:
 cd nginx-1.13.0/
 
 ./configure 
--prefix=/home/nginx 
--sbin-path=/home/nginx/sbin/nginx 
--conf-path=/home/nginx/conf/nginx.conf 
--error-log-path=/home/nginx/log/error.log 
--http-log-path=/home/nginx/log/access.log 
--pid-path=/home/nginx/run/nginx.pid 
--lock-path=/home/nginx/run/nginx.lock 
--http-client-body-temp-path=/var/cache/nginx/client_temp 
--http-proxy-temp-path=/var/cache/nginx/proxy_temp 
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp 
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp 
--http-scgi-temp-path=/var/cache/nginx/scgi_temp 
--user=nginx 
--group=nginx 
--with-http_ssl_module 
--with-http_realip_module 
--with-http_addition_module 
--with-http_sub_module 
--with-http_dav_module 
--with-http_flv_module 
--with-http_mp4_module 
--with-http_gunzip_module 
--with-http_gzip_static_module 
--with-http_random_index_module 
--with-http_secure_link_module 
--with-http_stub_status_module 
--with-http_auth_request_module 
--with-mail 
--with-mail_ssl_module 
--with-file-aio 
--with-ipv6 
--with-http_spdy_module 
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'


编译成功后:
make && make install
5.启动停止nginx
/home/nginx/sbin/nginx
/home/nginx/sbin/nginx -s stop
6.查看版本及安装的模块(大写的V):
/home/nginx/sbin/nginx -V
原文地址:https://www.cnblogs.com/byfboke/p/9366503.html