最近公司安排我安装几台云服务器环境 采用nginx做反向代理;
查了一下官方文档,参数比较多,很多在上线后 可能才知道注意一下的。
编译安装nginx的话 需要安装一些前置组件;
1.gcc环境;用于编译官方下载的源码包
e.g:yum install gcc-c++
2.zlib库; nginx的gzip需要使用zlib库
e.g:yum install -y zlib zlib-devel
3.perl库-PCRE;nginx中的http模块的东西需要pcre来解析
e.g:yum install -y pcre pcre-devel
4.OpenSS; 提供ssl协议,部分秘钥的支持;
e.g:yum install -y openssl openssl-devel
通过wget到nginx的gz文件,然后解压。
{nginx解压路径}/configure 可以直接运行configure进行编译;注重自定义以及维护掌握的话。可以研究下编译的参数
有大部分的参数:
直接安装成功后也可以使用nginx -V查看编译参数
--prefix=/etc/nginx
--sbin-path=/usr/sbin/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
--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=<path>
--with-cpp=<path>
--with-cc-opt=<options>
--with-ld-opt=<options>
-with-cpu-opt=<cpu>
--with-mail
--with-mail_ssl_module
--without-mail_pop3_module
--without-mail_imap_module
--without-mail_smtp_module
--without-http
--with-openssl=DIR
--without-http-cache
--with-http_perl_module
--with-perl_modules_path=PATH
--with-perl_modules_path=PATH
--http-log-path=PATH
--http-client-body-temp-path=PATH
--http-proxy-temp-path=PATH
--http-fastcgi-temp-path=PATH
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_xslt_module
--with-http_image_filter_module
--with-http_geoip_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gzip_static_module
--with-http_gunzip_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
大部分模块并不一定要设置;具体需要根据业务场景以及业务类型去做具体的设置;